簡體   English   中英

IE 11瀏覽器未在Selenium C#中關閉

[英]IE 11 browser not closing in Selenium C#

嘗試使用IE11驅動程序時。 它不會與driver.Close()driver.Quit

以下是我用於啟動和關閉的基本代碼。

//Declaring IE driver
IWebDriver driver = new InternetExplorerDriver();
//IWebDriver driver = new ChromeDriver();

//Navigate to test URL
driver.Navigate().GoToUrl("http://www.google.com");

//Close the browser
driver.Quit();
//driver.Close();

似乎像硒中的一個BUG:

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4288

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/65

您可以手動終止所有進程:

InternetExplorerOptions options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;

IWebDriver driver = new InternetExplorerDriver(options);
driver.Navigate().GoToUrl("http://www.google.com");

foreach (var process in Process.GetProcessesByName("IEDriverServer"))
{
    process.Kill();
}

foreach (var process in Process.GetProcessesByName("IExplore"))
{
    process.Kill();
}

我知道,這是一個丑陋的解決方法,它將關閉當前正在運行的所有Internet Explorer窗口,但是如果您需要自動運行此功能,至少它將清理資源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM