Selenium ChromeDriver WebDriver Error with TFS

We had a team recently who couldn’t get there Selenium tests to run via a TFS test build.  We kept getting the following error:

Test method IntegrationTests.Reports.ScheduleReportsTests.Validate_Report threw exception:

OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:6452/session timed out after 60 seconds. —> System.Net.WebException: The operation has timed out

TestCleanup method IntegrationTests.Reports.ScheduleReportsTests.TestCleanup threw exception. OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverEx

Researching

Step 1 was ensuring the test agent was setup to have an interactive session (see Donovan’s post for more details) which it was.  Most of our teams use the Firefox WebDriver and that was working without issue so that led us to start researching the ChromeDriver WebDriver further. 

We found a related post on Github by lukeis with some suggestions:

1)make a visual studio unit test project
2)write the selenium test inside the unit test file created with the project inside the tests method
3)make sure to add the no sandbox flag when starting up the chrome driver
4)make sure the TFS agent is running in interactive mode and not as a service
5)make sure to install chrome on the account that the agent uses

https://github.com/SeleniumHQ/selenium-google-code-issue-archive/issues/4817

Number 3 looked like the missing link so I researched further and found the “Chrome doesn’t start or crashes immediately” ChromeDriver documentation page:

https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start

Solution

This looked promising so we adjusted our ChromeDriver instantiation with the additional argument as follows:

DriverInitializer.ExtractSeleniumDriver(BrowserType.Chrome);
var options = new OpenQA.Selenium.Chrome.ChromeOptions {  };
options.AddArgument(“–no-sandbox”);
driver = new OpenQA.Selenium.Chrome.ChromeDriver(options);

And that did it!  I couldn’t find any further documentation on this “sandbox” but disabling it worked.

If you try this solution please add your results in the comments below so other readers will have further evidence/info about this solution.  Thanks!

Happy Selenium Testing!

Please follow and like us:

Leave a Reply