I\'m having troubles running Ruby/RSpec tests against Safari 11 when I\'m trying to run tests via ssh manually or via Jenkins (where machine where Safari exists is remote sl
For my case:
security unlock-keychain -p your_host_password /Users/$USER/Library/Keychains/login.keychain-db
safaridriver --enable
safaridriver -p 7050
open /Applications/StartSafariDriver7050.app/
run pytest cmd
osascript -e 'quit app "StartSafariDriver7050"'
pkill safaridriver
def safaridriver():
return webdriver.Safari(desired_capabilities=Caps.SAFARI, port=7050)
There is a possible workaround to do this. First you need to create a Automator Workflow or Apple Script that launches the SafariDriver
Then save this as a application. Let assume we name it SafariDriver7050
.
Then from the SSH session you need to execute
open /Applications/SafariDriver7050.app
This will actually launch SafariDriver in the logged in session and it should work for you.
The caveat being shutting it down, you will need to first kill the SafariDriver7050
app and then you need to kill the safaridriver
process. The order matters, else it will create a error dialog on UI
Edit-1:
As you suggested, it would be even easier to do this, when you wrap your test as a app and then it will be automatically be able to launch SafariDriver without any issues. The key to issue is using open
command in a SSH session
Edit-2
Why does SafariDriver not work in SSH? Well if you look at the linux counterpart
In case of linux we can use the DISPLAY environment variable to launch an app in an existing display or we can use something like XVFB to launch the browser in a virtual display. That is the concept that most frameworks use in case of linux machines.
But Mac doesn't have such kind of feature, which is why this workaround is needed. Now why it doesn't have that, I am not sure. There may be some other workaround that I may not be aware of, so anyone who has valuable info, can help improve this part of the answer