About SafariDriver
The SafariDriver is implemented as a Safari browser extension. The driver inverts the traditional client/server relationship and communicates with the WebDriver client using WebSockets.
Apple’s decision to drop Safari on Windows
The SafariDriver requires Safari 5.1+. Consequently, SafariDriver on Windows will most likely not work on newer versions of Safari and/or Windows because of Apple’s decision to drop Safari on Windows. Apple apparently kills Windows PC support in Safari 6.0
Safari 10 for desktop web automation
Need to do following set up before starting the execution:
- Ensure that the Develop menu is available. It can be turned on by opening Safari preferences (Safari > Preferences in the menu bar), going to the Advanced tab, and ensuring that the Show Develop menu in menu bar checkbox is checked.
- Enable Remote Automation in the Develop menu. This is toggled via Develop > Allow Remote Automation in the menu bar.
NOTE: Sometime you may face Unable to start the server: another safaridriver is already running. You can resolve this problem by running following command via terminal,
> launchctl list | grep webdriverd
> sudo kill xxxx
where xxxx is the process id of the webdriverd process. Which it looks like you may already have tried.
ServerSocket socket;
try {
socket = new ServerSocket(0);
socket.setReuseAddress(true);
port = socket.getLocalPort();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
SafariOptions options = new SafariOptions();
options.setUseCleanSession(true);
options.setPort(port);
driver = new SafariDriver(options);
Leave a Reply