简体   繁体   中英

How to launch Safari with Selenium WebDriver using Java

I have successfully installed safari developer certificate for safari driver. I have been built and added to safari extensions builder. The presteps are done. However when I run my selenium scripts, the safari server starts on a port and then I get following error in my eclipse console as shown below:

Oct 27, 2014 3:49:37 PM org.openqa.selenium.safari.SafariDriverServer start
INFO: Server started on port 22131
java.lang.IllegalAccessError: tried to access method com.google.common.base.Stopwatch.<init>()V from class org.openqa.selenium.safari.SafariDriverCommandExecutor
at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:99)
at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:115)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:101)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:94)

The safari browser open with giving error "Safari cant Find the File"

Any help would be appriciated thanks

Hi,
Setting up Selenium tests to run on Safari browser is a fairly complex process. You need to install Safari Extensions Developer Certificate in your machine and also install selenium webdriver as an extension in Safari Browser.

Also there are some stability issues with Safari browser automation & Selenium combination on Mac 10.9 OS and below. The stability is much better on Mac Yosemite OSX & Safari 8.0.x combination along with Selenium v2.45.0

Detailed steps for the setup can be seen here

Regards,
VJ

It might be a problem related to Webdriver version, please use the latest Webdriver version, Safari driver comes bundled with the the Webdriver just like the firefox driver and you could simply invoke the driver using the code below:

 SafariOptions options = new SafariOptions();
 options.setUseCleanSession(true); //if you wish safari to forget session everytime
 dvr = new SafariDriver(options); 

Starting with Selenium 2.30.0, the SafariDriver comes bundled with the Selenium server. If you wish to build the driver from source, head over to the SafariDriverInternals page. For now, grab a copy of the Selenium jar and add it to your classpath. Writing a test for Safari is just as straightforward as using the FirefoxDriver: To manually install the latest Safari extension (2.43.1): -

-

In latest Safari (10.0.1 as of today Nov 2016) WebDriver support is turned off by default. To turn on WebDriver support, do the following:

  • 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.
  • Authorize safaridriver to launch the webdriverd service which hosts the local web server. To permit this, once manually run safaridriver which is present at path /usr/bin/safaridriver and complete the authentication prompt.

Now safari is ready to run your webdriver scripts. For more details click here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM