I
I
Igor2017-12-03 11:14:39
proxy
Igor, 2017-12-03 11:14:39

How to run Chrome using Selenium WebDriver through proxy?

Hello.
How to run Chrome using WebDriver WebDriver through proxy?
I tried a bunch of options from the network, but did not get the result.
Or the ip does not change or the pages do not open at all ...
Here are the non-working options
Option 1

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
Proxy proxy = new Proxy();
proxy.setHttpProxy("myhttpproxy:3337");
capabilities.setCapability("proxy", proxy);
ChromeDriver driver = new ChromeDriver(capabilities);

Option 2
DesiredCapabilities caps = DesiredCapabilities.chrome();    
ArrayList<String> switches = new ArrayList<String>();    
switches.add("--proxy-server=myhttpproxy:3337);    
caps.setCapability("chrome.switches", switches);    
webDriver = new ChromeDriver(caps);

Option 3
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
СhromeOptions options = new ChromeOptions();
options.addArguments("--proxy-server=myhttpproxy:3337");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(capabilities);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question