Specflow
とWebDriver
のWebサイトをテストしています。 私はspecflowのイベントを使用してドライバを起動し、終了します。私は[BeforeFeature]
でドライバを起動し、[AfterFeature]
で終了します。SpecFlow WebDriver WebDriverの終了時または終了時のエラー
私はドライバを保持し、それを操作するための静的な共通クラスを使用します。
問題は、すべてのテストが機能で実行され、次の機能が起動した後に発生します。私が手)私はDriver.Quitを(行う場合
-> error: Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:7055
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\HttpCommandExecutor.cs:line 91
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Firefox\Internal\ExtensionConnection.cs:line 128
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 795
:[AfterFeature]
に私はDriver.Closeをすれば、私はエラーを取得する)(以下のエラー:
を取得しますエラー:
-> error: Cannot deserialize JSON object into type 'System.String'. Line 1, position 35.
ドライバを終了したり終了したりしないと、すべての機能は問題なく動作しますが、FirefoxのWindowsをたくさん開くようになります。
私のコードは次のとおりです。
[Binding]
public class Events
{
[BeforeFeature]
public static void BeforeFeature()
{
Common.CreateDriver();
}
[AfterFeature]
public static void AfterFeature()
{
Common.QuitDriver();
}
}
そして...
public static class Common
{
public static IWebDriver Driver { get; set; }
public static void CreateDriver(){
Driver = new FirefoxDriver();
Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5));
}
public static void CloseDriver()
{
Driver.Close();
}
public static void QuitDriver()
{
Driver.Quit();
}
}