![](/img/trans.png)
[英]Unit Tests Fail when “Run All” in Visual Studio but passes individually
[英]I am trying to run all tests in visual studio, but when I run the the tests the first one will pass, but all the others will fail
As above when I run all tests the only that passes is the 1st one,
I get the following stack trace.
Message: Initialization method QtpTest.ChromeTest7.Initiliize threw
exeption.OpenQa.selenium.WebdriverException:
OpenQa.selenium.WebDriverException: invalid session id
TestBase.cs
namespace QtpTest
{
[TestClass]
public class TestBase
{
[TestInitialize()]
public void Initialize()
{
Browser.Initialize();
}
[TestCleanup]
public void Cleanup()
{
Browser.Close();
}
}
}
我认为在第一次测试后返回测试初始化会话ID是错误的还是丢失了。
尽管这里几乎没有什么可做的,但过去在并行运行测试时遇到了这个问题。
我们在第一个测试将运行而其余的将失败的过程中也遇到了同样的问题。
这是由于共享存在访问问题(另一个程序正在使用文件)的chromedriver.exe。
我建议您尝试解决此问题,因为我不确定您是否并行运行以及如何创建驱动程序。
我认为正在发生的事情是通过只做browser.Quit()您的会话ID设置为第一个测试,并且当您进入下一个测试时,会生成一个新的会话ID,但它们不匹配,导致正在执行的测试无效会话ID。
类似于这篇文章中概述的内容
https://developer.mozilla.org/zh-CN/docs/Web/WebDriver/Errors/InvalidSessionID '
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.