Selenium chrome driver socks proxy configuration

一个人想着一个人 提交于 2019-12-10 00:48: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?


回答1:


    ChromeOptions options = new ChromeOptions();
    options.addArguments("--proxy-server=socks5://" + host + ":" + port);
    WebDriver driver = new ChromeDriver(options);



回答2:


Have you tried using this chromium arg?

--proxy-server="socks5://host:port"


来源:https://stackoverflow.com/questions/22481389/selenium-chrome-driver-socks-proxy-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!