由于在当前版本的 Safari 和 safaridriver 中检测元素可见性的问题,如此处所述,我尝试使用 Safari Technology Preview 启动我们的测试。电话在这里:
return new SafariDriver("/Applications/Safari Technology Preview.app/Contents/MacOS/");
这似乎有效,因为它会在测试开始时启动 Safari Technology Preview。但是,在它启动后,什么也没有发生,我收到以下信息:
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 Technology Preview.app/Contents/MacOS/safaridriver 一次。
关于如何使它工作的任何想法?