Selenium chrome driver socks proxy configuration

2019-04-18 07:21发布

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?

2条回答
Fickle 薄情
2楼-- · 2019-04-18 07:40
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--proxy-server=socks5://" + host + ":" + port);
    WebDriver driver = new ChromeDriver(options);
查看更多
甜甜的少女心
3楼-- · 2019-04-18 07:49

Have you tried using this chromium arg?

--proxy-server="socks5://host:port"
查看更多
登录 后发表回答