Since upgrading to Safari 12, my automated scripts are now getting this error:
SessionNotCreatedError: Request body does not contain required parameter \'capabil
This issue happens because Safari 12 uses a new W3C webdriver protocol (source) which appears to be incompatible with the latest stable selenium-webdriver package (v3.6)
safaridriver
can be passed a --legacy flag to use the old protocol. Directly on the command line this would be done like: /usr/bin/safaridriver --legacy
This flag can be set on the driver in your node program as follows:
const webdriver = require('selenium-webdriver');
const safari = require('selenium-webdriver/safari');
new webdriver.Builder()
.usingServer(await new safari.ServiceBuilder().addArguments('--legacy').build().start())
.forBrowser('safari')
.build();
Here's documentation on the ServiceBuilder
API - https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/safari_exports_ServiceBuilder.html
A couple GitHub tickets cover this as well:
This will also work if you get an error for 'await' when trying @mjdease solution above.
new webdriver.Builder()
.usingServer(new safari.ServiceBuilder().addArguments('--legacy').build().start())
.forBrowser('safari')
.build();