0
我想將我的Seunium Nunit測試轉換爲Xunit,並且我被卡在驅動程序退出。儘管使用了driver.Quit(),但是Xunit沒有關閉測試中的Selenium webdriver。
儘管使用driver.Quit();但僅當測試失敗時,Xunit纔會關閉Selenium webdriver進程或chrome瀏覽器。
測試看起來像這樣
[Fact]
public void test1()
{
SetupTest();
//testing something that fails
TeardownTest();
}
SetupTest
internal static void SetupTest()
{
driver = new ChromeDriver();
verificationErrors = new StringBuilder();
driver.Navigate().GoToUrl(baseUrl);
driver.Manage().Window.Maximize();
}
TeardownTest
internal static void TeardownTest()
{
try
{
driver.Quit();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.Equal("", verificationErrors.ToString());
}
如何最小化獲取pagesource的網頁? – RedArmy