Using Safari Webdriver
Hi all:
Recently the selenium team has released the safaridriver extension than allows the communication between WebDriver and the browser.
However, this extension is only available for Safari 5+ and you need tune up you browser before you can install it. In addition, you need to compile the extension from the sources.
Here are all the steps with a few screenshots to help you in all the process.
I hope these steps be useful
Cheers,
Requisites
- You need Safari 5 +. You can get it from: http://www.apple.com/es/safari/download/
Installation steps
Safari Extension:
Compiling
If you dont want to compile the extension, or if you have problems when compiling, you can use download a precompiled extension from here (look for the SafariDriver.safariextension.zip file)
- Checkout the 16670 version of the selenium project. Download all the project, not just the safariDriver folder. ~150Mb
- Build the extension. You need java properly set in your system's settings.
- Register as an Apple Developer in https://developer.apple.com/programs/register/
- Join in the Safari development program https://developer.apple.com/devcenter/safari/renew/index.action
- Generate a Safari certificate https://developer.apple.com/certificates/index.action#safarilist
- Install the certificate
- Open Safari.
- In Safari, go to Preferences -> Advanced -> check the Show Development menu in menu bar.
- Go to develop -> show extension builder.
- Click on + (Add) -> Add extension
- Select the SafariDriver.safariExtension folder, located in
- Click on install
Call:
/**
* Sets safari driver
*
* @param context
* Current test context
*/
private void setSafariDriver()
{
getLogger().log(Level.INFO, "Starting safari");
if (isSupportedPlatform())
{
driver = new SafariDriver();
getLogger().log(Level.INFO, "Safari started correctly");
}
else
{
getLogger().log(Level.INFO, "Platform not valid.");
}
}
private static boolean isSupportedPlatform()
{
Platform current = Platform.getCurrent();
return Platform.MAC.is(current) || Platform.WINDOWS.is(current);
}
Testing:
You can try with a JUnit class
In example:
@Test
public void StartSafariWD() {
browser.start("safariWD");
browser.stop();
}
Labels: automated testing, selenium, test, tutorial, webdriver