Selenium webdriver 无法从azure管道运行selenium测试用例?

Selenium webdriver 无法从azure管道运行selenium测试用例?,selenium-webdriver,azure-devops,selenium-ide,Selenium Webdriver,Azure Devops,Selenium Ide,我用selenium IDE记录了一些测试用例。我用c#(nunit)语言导出了这些测试用例。由于测试用例必须编译成.dll文件,我使用visual studio community创建了一个库项目,并将我的测试用例粘贴到该项目中。然后,我构建此项目以生成从azure运行测试用例所需的所有必要.dll文件。在此之后,我将整个库项目文件夹推入azure repos(以及dll文件)。不幸的是,当我运行管道时,它在“VsTest-testAssemblies”任务中不断失败 来自azure日志的错误

我用selenium IDE记录了一些测试用例。我用c#(nunit)语言导出了这些测试用例。由于测试用例必须编译成.dll文件,我使用visual studio community创建了一个库项目,并将我的测试用例粘贴到该项目中。然后,我构建此项目以生成从azure运行测试用例所需的所有必要.dll文件。在此之后,我将整个库项目文件夹推入azure repos(以及dll文件)。不幸的是,当我运行管道时,它在“VsTest-testAssemblies”任务中不断失败

来自azure日志的错误消息-

Running all tests in d:\a\1\s\chrometest\chrometest\bin\Debug\chrometest.dll
   NUnit3TestExecutor converted 1 of 1 NUnit test cases
  X createnewfolderonly [18s 200ms]
  Error Message:
   OpenQA.Selenium.NoSuchElementException : no such element: Unable to locate element: {"method":"css selector","selector":".butt > span"}
  (Session info: chrome=80.0.3987.132)
  Stack Trace:
     at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByCssSelector(String cssSelector)
   at OpenQA.Selenium.By.<>c__DisplayClass23_0.<CssSelector>b__0(ISearchContext context)
   at OpenQA.Selenium.By.FindElement(ISearchContext context)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
   at DefaultSuiteTest.createnewfolderonly() in C:\Users\Admin\source\repos\chrometest\chrometest\chrometestpage.cs:line 33

在d:\a\1\s\chrometest\chrometest\bin\Debug\chrometest.dll中运行所有测试
NUnit3TestExecutor转换了1个NUnit测试用例中的1个
X createnewfolderonly[18s 200ms]
错误消息:
OpenQA.Selenium.NoSuchElementException:没有这样的元素:无法找到元素:{“方法”:“css选择器”,“选择器”:.butt>span}
(会话信息:chrome=80.0.3987.132)
堆栈跟踪:
在OpenQA.Selenium.Remote.RemoteWebDriver.UnpackantRownerError(响应错误响应)中
在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(stringdrivercommandtoexecute,Dictionary`2参数)
在OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(字符串机制,字符串值)
在OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByCssSelector(字符串cssSelector)中
在OpenQA.Selenium.By.c__显示类23_0.b_0(ISearchContext)
在OpenQA.Selenium.By.FindElement(ISearchContext)上
位于OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By)
在C:\Users\Admin\source\repos\chrometest\chrometest\chrometestpage.cs中的DefaultSuiteTest.createnewfolderonly()处:第33行
注意:我可以使用命令promp在本地计算机上直接通过vstest.console.exe运行dll,没有任何问题,并且我没有收到任何这些错误。我还可以看到在此之后发生的自动化。为什么我不能从azure管道执行相同的操作?Plz帮助


有时,在本地运行UI测试比在服务器上运行快,并且在调用该方法时所需的元素没有完全加载。因此,您会看到上面的错误
无法定位元素…

您可以尝试为VsTest任务选中选项
测试组合包含UI测试。或者设置为重新运行失败的测试几次

您还可以尝试在测试代码中为ElementExists()使用
WebDriverWait以确保元素可见。有关更多信息,请查看


希望以上帮助

您的定位器无法找到要查找的元素。这可能是因为网站加载速度慢。您可以在脚本中的每一行之前等待,或者您可能给出了错误的位置

例如:

 Thread.Sleep(3000);  //3 seconds wait
 driver.FindElement(By.Name("q"));   // finding element by name

您好,您是否查看了下面提到的解决方案,进展如何?