2017-02-01 14 views
0

Из-за проблемы обнаружения видимости элементов в текущей версии Safari и safaridriver, как упоминалось here, я попытался запустить наши тесты с использованием технологии Safari Предварительный просмотр. Звонок здесь:Получение «Ошибка: соединение с подключением (соединение отказано)» при запуске safaridriver с использованием Safari Technology Preview

return new SafariDriver("/Applications/Safari Technology Preview.app/Contents/MacOS/"); 

Это похоже на работу, поскольку он запускает предварительный просмотр технологии Safari при начале теста. Однако, после того, как он будет запущен, ничего не происходит, и я получаю следующее:

Error: ConnectFailure (Connection refused) 

Полный StackTrace здесь:

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 

Примечание: Я не получаю эту ошибку, если я использую текущую версию релиз Сафари.

Я реализовал код в dotnet, используя Selenium 3.0.1. Я использую Safari Technology Preview v. 22, macOS Sierra 10.12.3. Разрешить удаленную автоматизацию проверяется в меню «Разработка». Я запускал/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver один раз вручную.

Любые идеи о том, как это сделать?

ответ

2

В 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.

Надеюсь, это полезно. :)

+0

Спасибо, с последней версией selenium для C#, я больше не получаю ошибку подключения. Я думаю, что это была функция, которая еще не была реализована для привязок C#. – champ12

 Смежные вопросы

  • Нет связанных вопросов^_^