SessionNotCreatedException when specifying `safari.options` and `port`
Meta -
OS: macOS 10.13.2
Selenium Version:
3.8.0/3.8.1
Browser:
Safari
Browser Version:
11.0.2
Expected Behavior -
If we start a remote driver with the following desired caps:
{'browserName': "safari", 'safari.options': {'port': 1034}
Actual Behavior -
The following exception and backtrace:
SessionNotCreatedException: Message: Unable to create new service: SafariDriverService
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'Tim-Sutton-SL0280.local', ip: 'fe80:0:0:0:8d6:1d46:d1a5:993d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.2', java.version: '9.0.1'
Driver info: driver.version: unknown
Stacktrace:
at org.openqa.selenium.remote.server.ServicedSession$Factory.lambda$get$0 (ServicedSession.java:208)
at org.openqa.selenium.remote.server.ServicedSession$Factory.apply (ServicedSession.java:218)
at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$11 (ActiveSessionFactory.java:167)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$11$1.accept (ReferencePipeline.java:375)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:177)
at java.util.Spliterators$ArraySpliterator.tryAdvance (Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential (FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:476)
at org.openqa.selenium.remote.server.ActiveSessionFactory.apply (ActiveSessionFactory.java:170)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$1 (NewSessionPipeline.java:44)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.Collections$2.tryAdvance (Collections.java:4734)
at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential (FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:476)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$2 (NewSessionPipeline.java:47)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.stream.DistinctOps$1$2.accept (DistinctOps.java:175)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:177)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:177)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance (Streams.java:397)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance (Streams.java:720)
at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential (FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:476)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession (NewSessionPipeline.java:50)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute (BeginSession.java:77)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0 (WebDriverServlet.java:240)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:514)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:844)
Steps to reproduce -
Start selenium standalone on macOS:
java -jar selenium-server-standalone-3.8.1.jar
Connect to it (using Python as an example):
from selenium import webdriver
driver = webdriver.Remote('http://localhost:4444/wd/hub', {'browserName': "safari", 'safari.options': {'port': 1034}})
If I omit the port option, it's fine.
Other notes
When looking further to the actual /usr/bin/safaridriver process that gets launched, that on prior versions of SE that it sets a random --port option anyway. (Looking at this line here)
Is it possible this was only functional with the old 2.x Safari extension? I looked a little and couldn't find any documentation for the port safari.options. I guess I just thought it was interesting that this version has that exception, even if it would not normally result in an explicit port being set anyway.
Thanks for your time and consideration!
I confirm it's reproducible. It looks like a bug in standalone (potentially a regression since e9253049cfb8fb20cdc3040e6a6de1d6f987aff5).
Relates to #5307 and #5020.
A few things about this in Selenium 4...
- This is not failing anymore since
safari.optionsis deprecated and not W3C compliant, so it is stripped from the caps. - Since this commit, it is not possible to pass the port as an option to
SafariOptions. Recommended way to do that is through aSafariDriver, - It is not possible to set a
portfor a Grid, it also does not add much value since one one Safari session can be executed at the same time.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.