2013-08-12 3 views
1

저는 셀렌과 IE 웹 드라이버를 사용하고 있습니다. 내 테스트가 시작될 때마다 IE 드라이버 서버도 시작되지만 테스트가 끝나면 닫히거나 종료되지 않습니다. 따라서 다음 테스트를 실행하기 위해 IEDriverServer.exe 개의 프로세스가 여러 개 설치되어 있습니다. 테스트를 마친 후에 어떻게 닫을 수 있습니까?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을 사용할 수 있습니다 알고 있지만, 셀레늄 솔루션이 좋을 것입니다.

답변

4

ie.Quit();을 사용해 보셨나요?

documentationsource code을 참조하십시오.

Quit()은 완전히 종료되는 브라우저입니다 (브라우저 및 드라이버).

Close()은 브라우저 창을 닫는 데 사용됩니다. 여기가 귀하의 경우 IEDriverServer.exe이 열린 채로 남아있는 이유입니다.

/// <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(); 
} 
( InternetExplorerDriver.cs의 기본 클래스는)

RemoteWebDriver.cs

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(); 
관련 문제