[Selenium] Chromium with --headless and --proxy-server settings error

7,599 views
Skip to first unread message

Moussa Oumar

unread,
May 10, 2017, 12:56:45 AM5/10/17
to Selenium Users
Hello,

I have been using a headless browser to generate screenshots of various WebPages, and it's been working perfectly.
 
This is what the working code:

DesiredCapabilities chrome = DesiredCapabilities.chrome();
 ChromeOptions chromeOptions = new ChromeOptions();
 chromeOptions.addArguments("--headless");
 chromeOptions.addArguments("--window-size=1400,900");
chrome.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

I am able to retrieve the content of a page, and generate a screenshot fine.

However, I need to make a change, and use a socks5 proxy.
Once I add a "--proxy-server" to the list of arguments,  everything breaks

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--proxy-server=socks5://localhost:xxxx");
(Where xxxx is the port my socks proxy is at - This is working perfectly outside of selenium, or when I launch Chrome through terminal with the --proxy-server=socks5://localhost:xxxx flag)
chromeOptions.addArguments("--window-size=1400,900");
chrome.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

This just has Selenium hanging, and throwing an exception

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.10.13-1-ARCH x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.01 seconds

 
Any idea on what might be going on  / how to fix it? 

Selenium Standalone 3.4
ChromeDriver 2.29

Thanks!
Message has been deleted

Moussa Oumar

unread,
May 10, 2017, 5:00:42 PM5/10/17
to Selenium Users
Bumping this :)

Felix Ka

unread,
May 12, 2017, 9:21:12 AM5/12/17
to Selenium Users
Hi,
I am facing a similar issue:

ChromeOptions options = new ChromeOptions();
options.setBinary("/usr/bin/chromium-browser");
options.addArguments("--headless");
options.addArguments("--proxy-server=http://my.proxy.com:8080","--proxy-bypass-list=https://to.be.bypassed:9002",  "window-size=1920x1080");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);

Using Chrome version: Version 60.0.3088.3 (Official Build) dev (64-bit)
Selenium: 3.4
Chromedriver: 2.29

It works fine with the proxy until I need to access sites within the corporate network and therefore try to set the --proxy-bypass-list parameter.

Best regards
Felix

BrianB VerveQA

unread,
Sep 21, 2017, 1:48:54 PM9/21/17
to Selenium Users
This is still occurring on Chromedriver 2.32, Version 61.0.3163.91 (Official Build) (64-bit).
Unfortunately, I cannot use any kind of proxy utilities (e.g. Browsermob Proxy) as it does not load anything properly.

Stefan Hofmann

unread,
Sep 27, 2017, 12:07:57 PM9/27/17
to Selenium Users
Hi,

I have problems using the parameters "--proxy-bypass-list" and "headless" together.
In this combination I got timeout for every request. The proxy settings work fine without headless parameter.


ChromeDriver 2.32.498550
Chrome 61.0.3163.100
Selenium 3.4
 

Regards, Stefan

EyalC

unread,
Dec 27, 2017, 4:39:06 AM12/27/17
to Selenium Users
Id someone find a solutions?

I'm also having trouble to unset proxy with headless chrome.

When doing 
Proxy proxyInst = new Proxy();
proxyInst.setProxyType(Proxy.ProxyType.DIRECT);

It is working for chrome but not working for chrome headless.

Any idea?

EyalC

unread,
Dec 27, 2017, 5:48:08 AM12/27/17
to Selenium Users
I find out a solution to use direct network connection (no proxy) with headless chrome (Tested with chrome 63 driver 2.34):

ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments("--no-sandbox");

options.addArguments("--proxy-server='direct://'");
options.addArguments("--proxy-bypass-list=*")
;

DesiredCapabilities browserCapabilities = DesiredCapabilities.chrome();
browserCapabilities.setCapability(ACCEPT_SSL_CERTS,true);
browserCapabilities.setCapability(TAKES_SCREENSHOT,true);
browserCapabilities.setCapability(SUPPORTS_ALERTS,true);
options.setAcceptInsecureCerts(true);
options.merge(browserCapabilities);


Enjoy

On Wednesday, May 10, 2017 at 7:56:45 AM UTC+3, Moussa Oumar wrote:

kumar maddula

unread,
Mar 18, 2019, 8:54:47 AM3/18/19
to Selenium Users
Use --proxy-auto-detect to get the headless chrome running

            options = webdriver.ChromeOptions()
            options.add_argument("--headless")
            options.add_argument("--proxy-auto-detect")
Reply all
Reply to author
Forward
0 new messages