SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.66k stars 8.19k forks source link

Selenium 3 - Safaridriver #2680

Closed Lightmoor closed 8 years ago

Lightmoor commented 8 years ago

Meta -

OS: OSX Selenium Version: 3.0.0 Beta 2 Browser:
Safari 10 - remote automation enabled

I create a selenium Node and Hub

java -jar selenium-server-standalone3.0.0-beta2.jar -role node -browser browserName=safari,maxInstances=1,platform=mac -maxSession 1 -browserTimeout 120 -timeout 120

java -jar selenium-server-standalone3.0.0-beta2.jar -role node

Now i want to run a test.

The session request come in. Nothing happens After a few seconds I get an exception

The test works on other browsers

DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); desiredCapabilities.setCapability("browserName", "safari") new RemoteWebDriver(new URL(TestConfig.DESTINATION + ":" + TestConfig.PORT + "/wd/hub"), desiredCapabilities)

19:27:14.730 INFO - Executing: [new session: Capabilities [{browserName=safari}]]) 19:27:14.758 INFO - Creating a new session for Capabilities [{browserName=safari}] 19:27:34.948 WARN - Exception thrown java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101' 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:36) 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:204) at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808) at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.seleniumhq.jetty9.server.Server.handle(Server.java:499) at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310) at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257) at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101' 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:209) 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) ... 1 more 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: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101' Driver info: driver.version: SafariDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143) at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:78) at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:69) ... 14 more Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ... at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76) at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:171) at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:649) ... 19 more 19:27:34.965 WARN - Exception: The process has not exited yet therefore no result is available ... 19:27:35.072 INFO - Executing: [new session: Capabilities [{browserName=safari}]]) 19:27:35.073 INFO - Creating a new session for Capabilities [{browserName=safari}] 19:27:55.142 WARN - Exception thrown java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101' 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:36) 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:204) at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808) at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.seleniumhq.jetty9.server.Server.handle(Server.java:499) at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310) at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257) at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101' 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:209) 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) ... 1 more 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: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101' Driver info: driver.version: SafariDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143) at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:78) at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:69) ... 14 more Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ... at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76) at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:171) at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:649) ... 19 more 19:27:55.143 WARN - Exception: The process has not exited yet therefore no result is available ...

After that I tried

https://webkit.org/blog/6900/webdriver-support-in-safari-10/

but this also get me an exception

======================================================================
ERROR: test_feature_status_page_filters (__main__.WebKitFeatureStatusTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_webkit.py", line 22, in test_feature_status_page_filters
    self.driver.get("https://webkit.org/status/")
AttributeError: 'WebKitFeatureStatusTest' object has no attribute 'driver'

======================================================================
ERROR: test_feature_status_page_search (__main__.WebKitFeatureStatusTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_webkit.py", line 8, in test_feature_status_page_search
    self.driver.get("https://webkit.org/status/")
AttributeError: 'WebKitFeatureStatusTest' object has no attribute 'driver'

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (errors=2)

any idee to solve this problem?

or is it a Bug?

lukeis commented 8 years ago

It seems like you're trying to run on El Capitan. Were you able to install Safari 10 on it? When I installed the technical preview it showed up as Safari 9.1.2...

If you were able to install it on El Capitan, does the file /usr/bin/safaridriver exist for you? If it does, what happens when you try to run it manually. If it doesn't... well, you're at where i'm at and you can't run on El Capitan yet and need to use mac OS Sierra.

hypnoce commented 8 years ago

I have the same issue on El Capitain. I was able to install Safari 10 on El Capitain with my developper account. Seems that there is a Timeout coming from DriverService.java

protected void waitUntilAvailable() throws MalformedURLException {
    try {
      URL status = new URL(url.toString() + "/status");
      new UrlChecker().waitUntilAvailable(20, SECONDS, status);
    } catch (UrlChecker.TimeoutException e) {
      process.checkForError();
      throw new WebDriverException("Timed out waiting for driver server to start.", e);
    }
  }

The /status returns a 404 error. screen shot 2016-08-30 at 9 12 48 am

I believe this is on Apple's side. But I'm not sure.

jleyba commented 8 years ago

Sadly, /status is not a command in the W3C spec. We'll need to update the java code to ping another end point to determine if the server is up and receiving requests (either that or treat 404 for /status as the server being up)

Lightmoor commented 8 years ago

The file /usr/bin/safaridriver exists. I use Safari 10

bildschirmfoto 2016-08-30 um 09 20 02 bildschirmfoto 2016-08-30 um 09 20 20

hypnoce commented 8 years ago

I believe a 404 error shows the server is up since it is responding to request (in that case an invalid request). Maybe only check if the port is open like the GeckoDriverService.

Lightmoor commented 8 years ago

my problem is that nothing happens. Safari didn't start.

I try an update on mac OS Sierra

hypnoce commented 8 years ago

It did not start because Selenium thinks the webdriver web server is not running properly.

Lightmoor commented 8 years ago

mac OS Sierra is installed but the problem is the same

any idea to solve this problem

hypnoce commented 8 years ago

Basically, this fix #2685 should allow you to use selenium with the new safari driver. Beware that not all features are implemented/stable in the new safaridriver.

lukeis commented 8 years ago

also... I've just downloaded and installed Safari 10 on El Cap... when I run safaridriver -p 4444 from terminal it just exits immediately, trying to reach out to apple about that. Hopefully that's just me :)

hypnoce commented 8 years ago

Maybe the port is already taken !

lukeis commented 8 years ago

nope... i tried with safaridriver -p 0 also

lukeis commented 8 years ago

(and various other random ports)

hypnoce commented 8 years ago

I'm on Safari Version 10.0 (11602.1.50.0.5) El Capitain Version 10.11.6 (15G31)

lukeis commented 8 years ago

Safari 10.0 (11602.1.50.0.5) OSX 10.11.6 (15G31)

here too... so... ¯\_(ツ)_/¯

JordiGiros commented 8 years ago

I'm just at the same point of you guys. El capitan and safari 10 beta 7. Selenium gives me "Could not open connection: An unknown server-side error occurred while processing the command."

Neither port 0, 4444 or 5555 works. If I find something I'll tell you.

hypnoce commented 8 years ago

The issue here was more that Selenium thought the safaridriver was not running when it was actually running. Do you have a more precise stacktrace and/or test case to reproduce ?

JordiGiros commented 8 years ago

Yes. Here it is. But I think there are some lines that shows us that is the same problem.

15:57:01.285 INFO - Executing: [new session: Capabilities [{marionette=false, browser=safari, name=Behat feature suite, browserName=safari, ignoreZoomSetting=false, version=, platform=MAC, tags=[Admins-MacBook-Pro-4.local, PHP 5.6.16]}]])

15:57:01.337 INFO - Creating a new session for Capabilities [{marionette=false, browser=safari, name=Behat feature suite, browserName=safari, ignoreZoomSetting=false, version=, platform=MAC, tags=[Admins-MacBook-Pro-4.local, PHP 5.6.16]}]

15:57:21.483 ERROR - org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

15:57:22.096 WARN - Exception thrown

java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException

Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'

System info: host: 'Devs-Mac-mini.local', ip: '192.168.10.159', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'

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:36)

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:204)

at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808)

at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587)

at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)

at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515)

at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061)

at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)

at org.seleniumhq.jetty9.server.Server.handle(Server.java:499)

at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310)

at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257)

at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540)

at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)

at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException

Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'

System info: host: 'Devs-Mac-mini.local', ip: '192.168.10.159', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'

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:209)

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)

... 1 more

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: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'

System info: host: 'Devs-Mac-mini.local', ip: '192.168.10.159', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'

Driver info: driver.version: SafariDriver

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)

at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:78)

at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:69)

... 14 more

Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.

Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'

System info: host: 'Devs-Mac-mini.local', ip: '192.168.10.159', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'

Driver info: driver.version: SafariDriver

at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)

at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:649)

... 19 more

Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:26614/status] to be available after 20004 ms

at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)

at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)

... 22 more

Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException

at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)

at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)

... 23 more

Caused by: java.util.concurrent.TimeoutException

at java.util.concurrent.FutureTask.get(FutureTask.java:205)

at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)

... 24 more

15:57:22.132 WARN - Exception: null
JordiGiros commented 8 years ago

I'm using Selenium 3.0 beta2 in grid mode. Using Safari 9 and the old safaridriver extension, tests were working. After the upgrade, it fails.

lukeis commented 8 years ago

@jordigiros I've logged a bug with apple for the safaridriver quitting immediately on El Cap.

FYI @burg it's not just me ;)

JordiGiros commented 8 years ago

@lukeis Only asking. Do you know if this new safaridriver will implement all webdriver API inlcuding mouse events?

kapythone commented 8 years ago

@lukeis I had the same problem, finally I figured it out. safaridriver exit immediately just because webdriverd is not running. You can check the status through: launchctl list | grep webdriverd

To make this daemon running, just use this command: launchctl load /System/Library/LaunchAgents/com.apple.webdriverd.plist

Then you should load safaridriver successfully.

Another issue is that SafariDriver does not work, after reviewing the trace logs, it seems to invoke DriverCommandExecutor instead of SafariDriverCommandExecutor, this is not expected. You can see the last commit might cause this issue: https://github.com/SeleniumHQ/selenium/commit/4e1cf8fdd2e4d1afa7563f14a4e18c1dfeacd2e2

kapythone commented 8 years ago

Currently there is a quick fix to make Safari run.

First you need to start safaridriver manually: safaridriver -p 8888

Then you should use RemoteDriver way:

        int port  = 8888;

        SafariOptions options = new SafariOptions();

        options.setPort(port);
        options.setUseCleanSession(true);

        DesiredCapabilities capabilities = DesiredCapabilities.safari();
        capabilities.setCapability(SafariOptions.CAPABILITY, options);

        RemoteWebDriver driver = null;
        try {
             driver = new RemoteWebDriver(new URL("http://localhost:" + port), capabilities);
             driver.get("http://www.google.com");

        }
        catch (Exception e){
            System.out.print(e);

        }
Lightmoor commented 8 years ago

I try the Bugfix from @hypnoce

after that the browser starts but with a error message safarierror

NODE Log 17:17:15.330 INFO - Executing: [new session: Capabilities [{acceptSslCerts=true, browserName=safari, platformName=MAC}]]) 17:17:15.333 INFO - Creating a new session for Capabilities [{acceptSslCerts=true, browserName=safari, platformName=MAC}] 17:17:15.338 INFO - Server started on port 46634 17:17:15.341 INFO - Launching Safari 17:17:15.342 INFO - Waiting for SafariDriver to connect 17:17:25.344 INFO - Shutting down 17:17:25.344 INFO - Stopping Safari 17:17:25.433 INFO - Stopping server 17:17:25.433 INFO - Stopping server 17:17:25.434 INFO - Shutdown complete 17:17:25.435 INFO - Shutting down 17:17:25.435 INFO - Stopping server 17:17:25.436 INFO - Shutdown complete 17:17:25.439 WARN - Exception thrown java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '3.0.0-beta3', revision: '', time: '2016-08-31 10:25:48 +0200' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' 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:36) at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111) at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:178) at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204) at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808) at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.seleniumhq.jetty9.server.Server.handle(Server.java:499) at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310) at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257) at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '3.0.0-beta3', revision: '', time: '2016-08-31 10:25:48 +0200' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' 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:209) 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) ... 1 more 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 10092 ms Build info: version: '3.0.0-beta3', revision: '', time: '2016-08-31 10:25:48 +0200' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' Driver info: driver.version: SafariDriver at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:118) at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:116) at org.openqa.selenium.remote.RemoteWebDriver.startClient(RemoteWebDriver.java:284) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117) at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:78) at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:69) ... 14 more 17:17:25.445 WARN - Exception: Failed to connect to SafariDriver after 10092 ms Build info: version: '3.0.0-beta3', revision: '', time: '2016-08-31 10:25:48 +0200' System info: host: 'test-Mac-mini.local', ip: '10.66.11.176', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' Driver info: driver.version: SafariDriver

Selenium Server Log

17:17:04.887 INFO - Got a request to create a new session: Capabilities [{acceptSslCerts=true, browserName=safari, platformName=MAC}] 17:17:04.888 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=safari, maxInstances=1, platform=MAC} 2016-08-31 17:17:15.309:WARN:osjs.ServletHandler:qtp2104545713-16: /wd/hub/session java.io.IOException: java.lang.NullPointerException at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:126) at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808) at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:221) at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.seleniumhq.jetty9.server.Server.handle(Server.java:499) at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310) at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257) at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at org.openqa.grid.web.servlet.handler.WebDriverRequest.extractDesiredCapability(WebDriverRequest.java:70) at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.<init>(SeleniumBasedRequest.java:103) at org.openqa.grid.web.servlet.handler.WebDriverRequest.<init>(WebDriverRequest.java:40) at org.openqa.grid.web.servlet.handler.WebDriverRequestFactory.createFromRequest(WebDriverRequestFactory.java:30) at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.createFromRequest(SeleniumBasedRequest.java:74) at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:81) at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808) at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:221) at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.seleniumhq.jetty9.server.Server.handle(Server.java:499) at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310) at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257) at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) 17:17:15.323 INFO - Got a request to create a new session: Capabilities [{acceptSslCerts=true, browserName=safari, platformName=MAC}] 17:17:15.323 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=safari, maxInstances=1, platform=MAC}

hypnoce commented 8 years ago

I think you might have installed the deprecated safari driver. Remove it first. Works on my side.

screen shot 2016-08-31 at 6 39 06 pm

BTW, try first without a selenium grid to see if it works on a simpler test case.

lukeis commented 8 years ago

would appreciate people logging new issues now for safari driver issues (and mostly with apple at https://bugreport.apple.com/ ).

We prefer to not have our issues on the selenium project turn into discussion threads, please feel free to start one on our google group: https://groups.google.com/forum/#!forum/selenium-users

to @JordiGiros 's question. I believe the first priority of that apple safaridriver is to implement the W3C WebDriver spec, although I believe they have attempted to implement some of Selenium's JSON Wire Protocol. (I don't work for apple, nor do I work on safaridriver)

With all that being said, the original issue reported here has been fixed (java server wasn't waiting appropriately for the safaridriver to start) and will be available in the next beta release (b3). Locking this issue as it has become off-topic to the original report (apologies, I did much of the off-topic-ing :) )

lukeis commented 8 years ago

My referenced bug with apple due to safaridriver not launching on El Cap is 28077636 (I don't know how to make it public nor how to link directly to it, if possible at all)

Appears I didn't read the comment above and this fixes it for me:

You can check the status through:
launchctl list | grep webdriverd

To make this daemon running, just use this command:
launchctl load /System/Library/LaunchAgents/com.apple.webdriverd.plist