Selenium chrome driver socks proxy configuration

skuzuc picture skuzuc · Mar 18, 2014 · Viewed 20.8k times · Source

I am having troubles in setting socks proxy for chrome driver

Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.MANUAL);
proxy.setAutodetect(false);
proxy.setSocksProxy(ProxyHelper.PROXY_HOST + ":" + ProxyHelper.PROXY_PORT);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.PROXY, proxy);
WebDriver chromeDriver = new ChromeDriver(capabilities);

This configuration gives:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot parse capability: proxy from unknown error: proxyType is 'manual' but no manual proxy capabilities were found

I think it expects me to fill http, ftp and ssl proxies. But if I fill them; error doesnt raise but my proxy does not work properly too as it tries to use it like http proxy rather than socks proxy.

What can I do?

Answer

Lin Hui picture Lin Hui · Mar 6, 2015
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--proxy-server=socks5://" + host + ":" + port);
    WebDriver driver = new ChromeDriver(options);