我正在使用Selenium和IE驱动程序。每当我的测试开始时,IE驱动服务器也会启动,但是它在测试完成后不会关闭/退出。因此,在下一次测试运行中,我将看到IEDriverServer.exe进程的多个实例。如何在测试运行后关闭它?
下面是我使用的示例代码:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var ie = new OpenQA.Selenium.IE.InternetExplorerDriver(new OpenQA.Selenium.IE.InternetExplorerOptions() {
IntroduceInstabilityByIgnoringProtectedModeSettings = true
});
ie.Navigate().GoToUrl("http://localhost:50640/");
ie.Close();
ie.Close(
Assert.IsTrue(true);
}
}我知道我可以使用ProcessInfo来杀死它,但是有一个Selenium解决方案会很好。
发布于 2013-08-12 22:45:59
你试过使用ie.Quit();吗?
请参考文档和源代码。
Quit()是完全退出的(浏览器和驱动程序)。
Close()用于关闭浏览器窗口。这就是为什么在这里,在您的例子中,IEDriverServer.exe是开放的。
IWebDriver.cs
/// <summary>
/// Close the current window, quitting the browser if it is the last window currently open.
/// </summary>
void Close();
/// <summary>
/// Quits this driver, closing every associated window.
/// </summary>
void Quit();RemoteWebDriver.cs (它是InternetExplorerDriver.cs)的基类)
/// <summary>
/// Closes the Browser
/// </summary>
public void Close()
{
this.Execute(DriverCommand.Close, null);
}
/// <summary>
/// Close the Browser and Dispose of WebDriver
/// </summary>
public void Quit()
{
this.Dispose();
}https://stackoverflow.com/questions/18197828
复制相似问题