![](/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.