【问题标题】:Integrating Selenium tests with tfs将 Selenium 测试与 tfs 集成
【发布时间】:2016-12-04 05:10:40
【问题描述】:

所以我已将我的 NUnit Seleniumt 测试放到我们团队的 tfs 中。我已将它们配置为作为 Visual Studio 测试构建和运行。我已将我的 VsoAgent 配置为交互式。我的测试开始运行,但在打开 Chrome 后,我看到 Chrome 自动化扩展程序已停止工作,并且出现错误:

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

当我在本地而不是通过 agent 运行它们时,一切正常。 有谁知道如何解决这个问题?

【问题讨论】:

    标签: selenium tfs nunit selenium-chromedriver agent


    【解决方案1】:

    尝试以下方法来缩小问题范围:

    • 更改默认(60 秒)驱动程序超时,在驱动程序中设置更多时间 构造函数

    • 将驱动程序更改为 Firefox 司机

    • 将 Selenium Webdriver Nuget 包升级到最新版本

    • 在构建代理上禁用防火墙。

    也可以看看类似的问题Selenium WebDriver throws Timeout exceptions sporadically & OpenQA.Selenium.WebDriverException : No response from server for url

    【讨论】:

      【解决方案2】:

      经过数小时的寻找,我找到了一个解决方案。我想让 ChromeDriver 在最新版本上运行,而 Chrome 在最新版本上运行。使它起作用的神奇线是:

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

      此行阻止 ChromeDriver 尝试以用户 SYSTEM 身份打开 Chrome,而他无法使用 VSO 代理处理。

      【讨论】:

      • 我建议您也接受这个作为答案,因为它完全符合您的要求,并且与我的情况完全相同
      猜你喜欢
      • 1970-01-01
      • 2011-06-14
      • 2013-05-26
      • 1970-01-01
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多