1 minute read

Create automated website tests for free with

If you need to run Selenium WebDriver UI tests in a browser that sends the traffic through a proxy, here is a code example of a Selenium test.
In this article we will show how easy it is to configure WebDriver to use a proxy by presenting a small code snippet that uses the FireFox driver and for which we set the HTTP, SSL and FTP proxy:

package com.webdriver.automation.tests;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.Proxy.ProxyType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class WebdriverUsingProxy {

private List<String> urlList = new ArrayList<String>();

public void setup() {

public void passTraffixThroughProxyTest() {
String httpProxy = "";
String sslProxy = "";
String ftpProxy = "";

DesiredCapabilities capability = new DesiredCapabilities();
addProxyCapabilities(capability, httpProxy, sslProxy, ftpProxy);

for (String url : urlList){
WebDriver driver = new FirefoxDriver(capability);

public static DesiredCapabilities addProxyCapabilities(DesiredCapabilities capability, String httpProxy, String sslProxy,
String ftpProxy) {
Proxy proxy = new Proxy();

capability.setCapability(CapabilityType.PROXY, proxy);
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
return capability;

In the code above we set the proxy type to manual and we’ve set the HTTP, SSL and FTP proxy to This is done using the Proxy object and setting the desired capability, pretty easy 🙂

If you want to see a easy and complete way to locate web elements check our last Selenium WebDriver blog post.

Have fun passing traffic through proxy in your tests. Also check Load Focus, our Cloud Load and Performance Application Testing Service. You can stress your app/website/API with thousands of concurrent users from all over the world.

Thanks for reading. I hope you learned something interesting about React!
If you found this article useful, please share it with others. Don’t forget to subscribe to get notified for the upcoming articles.