在VS测试中运行时,Selenium UI测试失败,但在Visual Studio中运行本地正常

时间:2017-09-06 21:15:26

标签: selenium azure-devops azure-pipelines

我们的质量保证分析师使用这些Nuget包编写了UI测试

  • NUnit 3.8.1
  • NUnit Console Runner 3.7.0
  • Nunit 3测试适配器3.8.0
  • Nunit Orange 2.1.0
  • Selenium Support 3.5.2
  • Selenium Web Driver 3.5.2
  • Selenium Web Driver IEDriver 3.5.1
  • Selenium Web Driver Wait Extensions 1.0.0

当我们在visual studio中打开解决方案并选择要运行的测试类别时,每个测试都会打开一个firefox浏览器,登录,导航到页面,检测元素并基本上通过。

但是,当我们使用Visual Studio的脚本版本时,在Visual Studio Test V2过程中,所有测试都会因此错误而失败:

测试失败A. 2017-09-06T19:09:01.3495462Z错误信息: 2017-09-06T19:09:01.3495462Z OpenQA.Selenium.ElementNotVisibleException: 2017-09-06T19:09:01.3495462Z堆栈跟踪: 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary 2 parameters) 2017-09-06T19:09:01.3495462Z at OpenQA.Selenium.Remote.RemoteWebElement.Click() 2017-09-06T19:09:01.3495462Z at x.Init.click(By locator) in E:\agent\_work\1\s\UI Tests\AutomatedTests(FF)\x\Init\Init.cs:line 362 2017-09-06T19:09:01.3495462Z at x.AbstractPage.expandMenuItem(By menuItemlocator) in E:\agent\_work\1\s\UI Tests\AutomatedTests(FF)\xSelenium\Pages\AbstractPage.cs:line 223 2017-09-06T19:09:01.3495462Z at xSelenium.AbstractPage.openAirlinesPage() in E:\agent\_work\1\s\UI Tests\AutomatedTests(FF)\xSelenium\Pages\AbstractPage.cs:line 775 2017-09-06T19:09:01.3495462Z at xSelenium.Acceptance.Acceptance_SeniorManager_OpenAndCheckLinksOnAirlinesPage() in E:\agent\_work\1\s\UI Tests\AutomatedTests(FF)\xSelenium\Tests\Acceptance.cs:line 750Standard Output Messages: 2017-09-06T19:09:01.3495462Z OpenQA.Selenium.WebDriverTimeoutException: Timed out after 25 seconds 2017-09-06T19:09:01.3495462Z at OpenQA.Selenium.Support.UI.DefaultWait 1.ThrowTimeoutException(String exceptionMessage,Exception lastException) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Support.UI.DefaultWait 1.Until[TResult](Func 2条件) 2017-09-06T19:09:01.3495462Z at xSelenium.Init.waitUntilElementIsNotVisible(By by)in E:\ agent_work \ 1 \ s \ UI Tests \ AutomatedTests(FF)\ xSelenium \ Init \ Init.cs:line 596 2017-09-06T19:09:01.3495462Z无法找到element:// span [text()=' OK'] 2017-09-06T19:09:01.3495462Z 启动错误堆栈跟踪 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary`2 parameters) 2017-09-06T19:09:01.3495462Z at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,String value) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.By。<> c__DisplayClasse.b__c(ISearchContext context) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.By.FindElement(ISearchContext context) 2017-09-06T19:09:01.3495462Z在OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by) 2017-09-06T19:09:01.3495462Z at xSelenium.Init.isElementPresent(By by)在E:\ agent_work \ 1 \ s \ UI Tests \ AutomatedTests(FF)\ xSelenium \ Init \ Init.cs:line 412 2017-09-06T19:09:01.3495462Z 错误堆栈跟踪结束

构建计算机正在运行Windows 10(另一台构建计算机运行Server 2012,并抛出相同的错误)

  • Firefox 55
  • Chrome版本60.0.3112.113

已启用这些Visual Studio测试选项:   - Test Mix包含UI测试

服务器上的代理处于交互模式并注册为Windows服务 - 它具有“允许服务与桌面交互”的权限。启用。

将SetPageLoadTimeout和SetScriptTimeout超时增加到120秒,但问题仍然存在。

1 个答案:

答案 0 :(得分:1)

运行功能测试时,通常需要使用Run Functional Tests任务在测试代理上运行。