Use proxies with Selenium

Learn how to set up resident and mobile proxies for test automation with Selenium.
Choose Plan 3 day trial • No set-up costs • Cancel anytime
  1. Firstly, you need to know that Selenium supports five programming languages: Java, C#, Python, Ruby, Javascript (Node). Depending on language you use, there are different ways to set up proxies

  2. Secondly, you need to choose WebDriver you want to use. Selenium offers WebDrivers to all the most popular browsers (you can see all supported drivers here). In our tutorial we'd like to use Google Chrome Driver

  3. There are some code examples for your preferred programming language and Google Chrome Driver

    package chromeScripts;
    import org.openqa.selenium.By;
    import org.openqa.selenium.Proxy;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    public class Example {
        public static void main(String[] args) {
            String ProxyServer = "";
            int ProxyPort = 9000;
            String sHttpProxy = ProxyServer + ":" + ProxyPort;
            Proxy proxy = new Proxy();
            ChromeDriverService service = new ChromeDriverService.Builder()
                                        .usingDriverExecutable(new File("PATH TO WEBDRIVER"))
            ChromeOptions options = new ChromeOptions();
            options.setCapability("proxy", proxy);
            WebDriver driver=new ChromeDriver(service, options);
            WebElement body = driver.findElement(By.tagName("body"));
            String bodyText = body.getText();

    You're able to run all of these commands in your Terminal/Command Prompt window

  4. To set up proxy connection please use line within the punctuation marks (''). Depending on your type of language, punctuation may differ

    • Java:
        String ProxyServer = "";
        int ProxyPort = 9000;
    • C#:
        HttpProxy = ""
    • Python:
         HOSTNAME = ''
         PORT = '9000'
    • Ruby:
         proxy = "")
    • Javascript (Node):
        let addr = ''

    All necessary data about server, port, login and password you can get from your Froxy Dashboard

Try Froxy Right Now

Proxies from Froxy fit most popular tools that allow you to achieve your goals!

Try a proxy right now, just create an account, choose a rate and get started.

Start now