Getting "Error: ConnectFailure (Connection refused)" when running safaridriver using Safari Technology Preview
Getting "Error: ConnectFailure (Connection refused)" when running safaridriver using Safari Technology Preview
由于在当前版本的 Safari 和 safaridriver 中检测元素可见性的问题,如前所述 ,我尝试使用 Safari Technology Preview 启动我们的测试。电话来了:
return new SafariDriver("/Applications/Safari Technology Preview.app/Contents/MacOS/");
这似乎可行,因为它会在测试开始时启动 Safari 技术预览。然而,启动后,什么也没有发生,我收到以下信息:
Error: ConnectFailure (Connection refused)
完整的堆栈跟踪在这里:
1) Error : TESTNAME
OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:62221/session. The status of the exception was ReceiveFailure, and the message was: Error getting response stream (ReadDone2): ReceiveFailure
----> System.Net.WebException : Error getting response stream (ReadDone2): ReceiveFailure
----> System.Exception : at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Net.WebConnection.ReadDone (System.IAsyncResult result) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Net.Sockets.SocketAsyncResult+<Complete>c__AnonStorey0.<>m__0 (System.Object _) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
TearDown : System.NullReferenceException : Object reference not set to an instance of an object
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse (System.Net.WebRequest request) [0x000ce] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute (OpenQA.Selenium.Remote.Command commandToExecute) [0x000bd] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute (OpenQA.Selenium.Remote.Command commandToExecute) [0x00038] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters) [0x00014] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession (OpenQA.Selenium.ICapabilities desiredCapabilities) [0x0001e] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor (OpenQA.Selenium.Remote.ICommandExecutor commandExecutor, OpenQA.Selenium.ICapabilities desiredCapabilities) [0x0001e] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (OpenQA.Selenium.Safari.SafariDriverService service, OpenQA.Selenium.Safari.SafariOptions options, System.TimeSpan commandTimeout) [0x0000e] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (System.String safariDriverDirectory, OpenQA.Selenium.Safari.SafariOptions options, System.TimeSpan commandTimeout) [0x00007] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (System.String safariDriverDirectory, OpenQA.Selenium.Safari.SafariOptions options) [0x00000] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (System.String safariDriverDirectory) [0x00007] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at Core.Selenium.SafariDriverFactory.CreateDriver (Core.Selenium.BrowserProfileManager profileManager) [0x00001] in <a2c49999051b4e8fb6c51d2ee4bca4b5>:0
at Core.Selenium.DriverController.CreateWebDriver (Core.Enums.DriverType type) [0x00078] in <a2c49999051b4e8fb6c51d2ee4bca4b5>:0
at Core.Selenium.DriverController..ctor (Core.Enums.DriverType type, System.DateTime creationTime, System.Boolean useProfile) [0x00045] in <a2c49999051b4e8fb6c51d2ee4bca4b5>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0
--WebException
at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse (System.Net.WebRequest request) [0x00008] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
--Exception
at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00044] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
注意:如果我使用当前发行版的 Safari,则不会出现此错误。
我已经使用 Selenium 3.0.1 在 dotnet 中实现了代码。我使用的是 Safari Technology Preview v. 22,macOS Sierra 10.12.3。在“开发”菜单中选中“允许远程自动化”。我有 运行 /Applications/Safari 技术预览。app/Contents/MacOS/safaridriver 一次手动。
关于如何让它工作有什么想法吗?
在 Python 中,这是我所做的:
driver = webdriver.Safari(port=0, executable_path="/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver")
driver.get("https://www.google.com")
您可能还想看看:
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/safari/SafariOptions.html
这里:https://github.com/SeleniumHQ/selenium/issues/3506
lmtierney 说:
That would depend on the language bindings you're using. You should be able to pass the executable path somewhere and it would be /Applications/Safari Technology Preview/Contents/MacOS/safaridriver. Some language bindings allow a flag to automatically use the tech preview safaridriver.
希望对您有所帮助。 :)
由于在当前版本的 Safari 和 safaridriver 中检测元素可见性的问题,如前所述
return new SafariDriver("/Applications/Safari Technology Preview.app/Contents/MacOS/");
这似乎可行,因为它会在测试开始时启动 Safari 技术预览。然而,启动后,什么也没有发生,我收到以下信息:
Error: ConnectFailure (Connection refused)
完整的堆栈跟踪在这里:
1) Error : TESTNAME
OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:62221/session. The status of the exception was ReceiveFailure, and the message was: Error getting response stream (ReadDone2): ReceiveFailure
----> System.Net.WebException : Error getting response stream (ReadDone2): ReceiveFailure
----> System.Exception : at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Net.WebConnection.ReadDone (System.IAsyncResult result) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Net.Sockets.SocketAsyncResult+<Complete>c__AnonStorey0.<>m__0 (System.Object _) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
TearDown : System.NullReferenceException : Object reference not set to an instance of an object
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse (System.Net.WebRequest request) [0x000ce] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute (OpenQA.Selenium.Remote.Command commandToExecute) [0x000bd] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute (OpenQA.Selenium.Remote.Command commandToExecute) [0x00038] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters) [0x00014] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession (OpenQA.Selenium.ICapabilities desiredCapabilities) [0x0001e] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor (OpenQA.Selenium.Remote.ICommandExecutor commandExecutor, OpenQA.Selenium.ICapabilities desiredCapabilities) [0x0001e] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (OpenQA.Selenium.Safari.SafariDriverService service, OpenQA.Selenium.Safari.SafariOptions options, System.TimeSpan commandTimeout) [0x0000e] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (System.String safariDriverDirectory, OpenQA.Selenium.Safari.SafariOptions options, System.TimeSpan commandTimeout) [0x00007] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (System.String safariDriverDirectory, OpenQA.Selenium.Safari.SafariOptions options) [0x00000] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at OpenQA.Selenium.Safari.SafariDriver..ctor (System.String safariDriverDirectory) [0x00007] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
at Core.Selenium.SafariDriverFactory.CreateDriver (Core.Selenium.BrowserProfileManager profileManager) [0x00001] in <a2c49999051b4e8fb6c51d2ee4bca4b5>:0
at Core.Selenium.DriverController.CreateWebDriver (Core.Enums.DriverType type) [0x00078] in <a2c49999051b4e8fb6c51d2ee4bca4b5>:0
at Core.Selenium.DriverController..ctor (Core.Enums.DriverType type, System.DateTime creationTime, System.Boolean useProfile) [0x00045] in <a2c49999051b4e8fb6c51d2ee4bca4b5>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0
--WebException
at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse (System.Net.WebRequest request) [0x00008] in <1d3f371c7d3240a69d2057d5d4e507e9>:0
--Exception
at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00044] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0
注意:如果我使用当前发行版的 Safari,则不会出现此错误。
我已经使用 Selenium 3.0.1 在 dotnet 中实现了代码。我使用的是 Safari Technology Preview v. 22,macOS Sierra 10.12.3。在“开发”菜单中选中“允许远程自动化”。我有 运行 /Applications/Safari 技术预览。app/Contents/MacOS/safaridriver 一次手动。
关于如何让它工作有什么想法吗?
在 Python 中,这是我所做的:
driver = webdriver.Safari(port=0, executable_path="/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver")
driver.get("https://www.google.com")
您可能还想看看: https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/safari/SafariOptions.html
这里:https://github.com/SeleniumHQ/selenium/issues/3506 lmtierney 说:
That would depend on the language bindings you're using. You should be able to pass the executable path somewhere and it would be /Applications/Safari Technology Preview/Contents/MacOS/safaridriver. Some language bindings allow a flag to automatically use the tech preview safaridriver.
希望对您有所帮助。 :)