自从昨晚升级到Safari 11以来,我的自动化测试不会针对safari运行。
应该注意的是,我使用' http://localhost:4444/wd/hub'远程运行。因为我发现“玻璃窗格”妨碍了我需要做的事情。
在我启动webdriver的终端中,它启动正常,然后返回以下错误:
更新:
23:23:25.398 INFO - Executing: [new session: Capabilities [{browserName=safari}]])
23:23:25.399 INFO - Creating a new session for Capabilities [{browserName=safari}]
23:23:25.404 INFO - Server started on port 26778
23:23:25.405 INFO - Launching Safari
23:23:25.406 INFO - Waiting for SafariDriver to connect
23:23:35.410 INFO - Shutting down
23:23:35.410 INFO - Stopping Safari
23:23:35.464 INFO - Stopping server
23:23:35.465 INFO - Stopping server
23:23:35.466 INFO - Shutdown complete
23:23:35.466 INFO - Shutting down
23:23:35.467 INFO - Stopping server
23:23:35.467 INFO - Shutdown complete
23:23:35.631 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ANTHONYs-MacBook-Pro.local', ip: '10.37.129.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:202)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:164)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ANTHONYs-MacBook-Pro.local', ip: '10.37.129.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
... 9 more
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Failed to connect to SafariDriver after 10060 ms
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ANTHONYs-MacBook-Pro.local', ip: '10.37.129.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: SafariDriver
at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:121)
at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:76)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:62)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:53)
... 14 more
23:23:35.634 WARN - Exception: Failed to connect to SafariDriver after 10060 ms
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ANTHONYs-MacBook-Pro.local', ip: '10.37.129.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: SafariDriver
在我运行自动脚本的终端窗口中,我看到了:
/Users/antb/Desktop/project/node_modules/selenium-webdriver/lib/promise.js:2626
throw error;
^
WebDriverError: Failed to connect to SafariDriver after 10060 ms
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ANTHONYs-MacBook-Pro.local', ip: '10.37.129.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: SafariDriver
at WebDriverError (/Users/antb/Desktop/project/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/Users/antb/Desktop/project/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/antb/Desktop/project/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/antb/Desktop/project/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (/Users/antb/Desktop/project/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at createDriver (/Users/antb/Desktop/project/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/Users/antb/Desktop/project/node_modules/selenium-webdriver/index.js:635:14)
at Object.<anonymous> (/Users/antb/Desktop/project/BigIdeas_POM.js:1157:6)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
我认为这可能是一些路径问题,但它让我想到了我需要做出具体改变的地方。我尝试了很多东西(升级到selenium 3.6.0 jar,升级node.js,升级java,这个Failed to connect to SafariDriver (Safari 10)等等,但那些没有成功。
浏览器简要地说:
SafariDriver Launcher
[ 0.024s] [safaridriver.client] Connecting to SafariDriver browser extension...
[ 0.041s] [safaridriver.client] This will fail if you have not installed the latest SafariDriver extension from
http://selenium-release.storage.googleapis.com/index.html
[ 0.042s] [safaridriver.client] Extension logs may be viewed by clicking the Selenium [✓] button on the Safari toolbar
答案 0 :(得分:1)
我看到你的safari客户端绑定是2.52,你应该使用3.6
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Failed to connect to SafariDriver after 10065 ms
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
检查你是否有最新版本的selenium-webdriver客户端绑定看看这个link
答案 1 :(得分:0)
我试过了:
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_65'
以及当前最新版本的Safari(版本11.0(12604.1.38.1.7))。
如果我使用Selenium 2.52.0不起作用。
如果我使用Selenium的current latest release,它就会起作用。
从您的例外情况来看,您使用的是 2.52.0 。你必须更新它。