Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium chrome driver socks proxy configuration

Tags:

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?

like image 410
skuzuc Avatar asked Mar 18 '14 13:03

skuzuc


People also ask

Can you use proxies with selenium?

Setting up a Proxy ServerImport Selenium WebDriver from the package. Define the proxy server (IP:PORT) Set ChromeOptions() Add the proxy server argument to the options.

What is Socks proxy port?

What Is a SOCKS Proxy? SOCKS, which stands for Socket Secure, is a network protocol that facilitates communication with servers through a firewall by routing network traffic to the actual server on behalf of a client. SOCKS is designed to route any type of traffic generated by any protocol or program.


2 Answers

    ChromeOptions options = new ChromeOptions();
    options.add_argument("--proxy-server=socks5://" + host + ":" + port);
    WebDriver driver = new ChromeDriver(options);
like image 174
Lin Hui Avatar answered Sep 27 '22 17:09

Lin Hui


Have you tried using this chromium arg?

--proxy-server="socks5://host:port"
like image 36
user2426679 Avatar answered Sep 27 '22 15:09

user2426679