Chrome with Selenium inside a Docker container running failed

491 views
Skip to first unread message

Gboye Show

unread,
Jul 2, 2019, 3:52:57 AM7/2/19
to Selenium Users
Hello everyone,

Running tests on the local computer through chromedriver works great, but I run tests
through a grid(on the local machine) the failure rate goes way up .Running a Chrome browser inside a Docker container with Selenium used to be a challenging
here is my code please let me know if I'm doing it wrongly. 
ChromeOptions options = new ChromeOptions();
System.setProperty("webdriver.chrome.driver","c:\\usr\\bin\\chromedriver\\chromedriver");
options.addArguments("no-sandbox");
options.addArguments("--disable-popup-blocking");
options.addArguments("-- disable-translate");
options.addArguments("--start-maximized");
options.addArguments("--headless");
options.addArguments("window-size=1200x600");
driver = new RemoteWebDriver(URI.create("http://127.0.0.1:4444/wd/hub").toURL(), options);
//driver.get("http://127.0.0.1:4444/wd/hub").toURL(), new ChromeOptions();
driver = new ChromeDriver(options);

⇜Krishnan Mahadevan⇝

unread,
Jul 2, 2019, 4:17:32 AM7/2/19
to Selenium Users
You should be able to extend the concept as shown in this sample code that I created wherein I spin off a Grid and a node on-demand as docker container.


You should be able to alter it and just resort to spinning off standalone nodes.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5f635ce5-d776-4f33-8685-4a5a9d06dc1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Doe

unread,
Jul 2, 2019, 4:52:11 AM7/2/19
to Selenium Users
One thing which looks suspicious is your webdriver.chrome.driver property value, in the vast majority of cases Docker containers are Linux-based and in Linux there is no C drive, all paths start from /.

So your Dockerfile should have a relevant RUN command to download and extract the relevant ChromeDriver for Linux and you need to amend your webdriver.chrome.driver property to point to the correct location. 

The same applies to the Selenium Grid

More information:

Reply all
Reply to author
Forward
0 new messages