首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何防止IEDriverServer.exe进程多次启动?

如何防止IEDriverServer.exe进程多次启动?
EN

Stack Overflow用户
提问于 2013-08-12 22:39:43
回答 1查看 1.4K关注 0票数 1

我正在使用Selenium和IE驱动程序。每当我的测试开始时,IE驱动服务器也会启动,但是它在测试完成后不会关闭/退出。因此,在下一次测试运行中,我将看到IEDriverServer.exe进程的多个实例。如何在测试运行后关闭它?

下面是我使用的示例代码:

代码语言:javascript
复制
[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解决方案会很好。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-12 22:45:59

你试过使用ie.Quit();吗?

请参考文档源代码

Quit()是完全退出的(浏览器和驱动程序)。

Close()用于关闭浏览器窗口。这就是为什么在这里,在您的例子中,IEDriverServer.exe是开放的。

IWebDriver.cs

代码语言:javascript
复制
/// <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)的基类)

代码语言:javascript
复制
/// <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();
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18197828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档