[英]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 TestBase.cs
namespace QtpTest
{
[TestClass]
public class TestBase
{
[TestInitialize()]
public void Initialize()
{
Browser.Initialize();
}
[TestCleanup]
public void Cleanup()
{
Browser.Close();
}
}
}
I think That after the 1st test when it goes back to test initioalize the session id is either wrong or missing. 我认为在第一次测试后返回测试初始化会话ID是错误的还是丢失了。
Though there is little to go off of here, I have had this issue in the past when running test in parallel. 尽管这里几乎没有什么可做的,但过去在并行运行测试时遇到了这个问题。
We were experiencing the same issue you are facing where the first test would run and the rest would fail. 我们在第一个测试将运行而其余的将失败的过程中也遇到了同样的问题。
This was due to sharing the chromedriver.exe having access issues (file in use by another program). 这是由于共享存在访问问题(另一个程序正在使用文件)的chromedriver.exe。
I have a suggestion to try and resolve this since i am unsure if you are running in parallel or not as well as how you are creating your driver. 我建议您尝试解决此问题,因为我不确定您是否并行运行以及如何创建驱动程序。
What i think is happening is by just doing browser.Quit() your session id is set to the first test, and when you go onto the next test a new session id is generated but they do not match causing the executing test to have invalid session id. 我认为正在发生的事情是通过只做browser.Quit()您的会话ID设置为第一个测试,并且当您进入下一个测试时,会生成一个新的会话ID,但它们不匹配,导致正在执行的测试无效会话ID。
Similar to what is being outline in this post 类似于这篇文章中概述的内容
https://developer.mozilla.org/en-US/docs/Web/WebDriver/Errors/InvalidSessionID ' https://developer.mozilla.org/zh-CN/docs/Web/WebDriver/Errors/InvalidSessionID '
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.