Search code examples
seleniumtfsnunitselenium-chromedriveragent

Integrating Selenium tests with tfs


So I have put my NUnit Seleniumt tests onto our team's tfs. I have configurated them to build and run as Visual Studio Tests. I have configurated my VsoAgent as interactive. My tests start to run, but after opening Chrome I see a communicate that Chrome automation extension has stopped working and I get an error:

OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:54836/session timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at SeleniumBase.Selenium_base.setUp(Browsers browser, String URL, Int32 waitMillis) in C:\TFS\agent3\_work\1\s\PentaJPKSelenium\Selenium_base.cs:line 38
at PentaJPKBase.PentaJPK_base.SetupTest() in C:\TFS\agent3\_work\1\s\PentaJPKSelenium\PentaJPKSelenium_base.cs:line 17
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--TearDown
at PentaJPKBase.PentaJPK_base.TeardownTest() in C:\TFS\agent3\_work\1\s\PentaJPKSelenium\PentaJPKSelenium_base.cs:line 54Error: Exception NUnit.Core.UnsupportedFrameworkException, Exception thrown executing tests in C:\TFS\agent3\_work\1\s\PentaJPKSelenium\bin\Debug\PentaJPKSelenium.dll

When I run them locally, not through agent , everything's working correctly. Does anyone know how to fix this?


Solution

  • I have found a soulution after hours of looking for it. I wanted to make ChromeDriver work on the latest version with Chrome on the latest version. The magic line that made it work was:

    ChromeOptions options = new ChromeOptions();
    options.AddArguments("no-sandbox"); <--------------------------
    driver = new ChromeDriver(options);
    

    This line stopped ChromeDriver from trying to open Chrome as user SYSTEM, which he cannot handle using VSO agent.