It has been a year and there is still no SafariDriver which extends WebDriver. Unfortunately, Safari 5.0 and 5.1 have hit the market and the Selenium 1.0 "*safari" driver is no longer working. As the Selenium look at dropping support for older web browsers they are also looking into supporting things like Safari 5.x.
Ideally, I would like to see:
WebDriver driver = new SafariDriver();
or
URL hub = new URL("http://localhost:4444/wd/hub");
DesiredCapabilities dc = DesiredCapabilities.safari();
WebDriver driver = new RemoteWebDriver(hub, dc);
Until this happens, we'll have to rely on using Selenium 1.0 to create an instance of Safari. But if "*safari" is no longer working and there are no plans to update it, what do we do? The solution appears to be use "*safariproxy" instead.
Looking at the code for SeleneseCommandExecutor() there are two constructors. The first takes as input a Selenium instance. The second takes as input a CommandProcessor. The second constructor actually calls the first constructor. So either method will work. So here it is:
String baseURL = "http://www.google.com";
Selenium sel = new DefaultSelenium("localhost", 4444, "*safariproxy", baseURL);
CommandExecutor executor = new SeleneseCommandExecutor(sel);
DesiredCapabilities dc = new DesiredCapabilities();
WebDriver browser = new RemoteWebDriver(executor, dc);
or
String baseURL = "http://www.google.com";
CommandProcessor cp = new HttpCommandProcessor("localhost", 4444, "*safariproxy", baseURL);
CommandExecutor executor = new SeleneseCommandExecutor(sel);
DesiredCapabilities dc = new DesiredCapabilities();
WebDriver browser = new RemoteWebDriver(executor, dc);
Additionally, if the browser cannot be found, i.e. it is not in the default locations, then you can specific the path to the Safari executable using:
"*safariproxy /Application/Safari.app/Contents/MacOS/Safari"
This code is untested but hopefully better then the previous example.
Happy automating.
.
This comment has been removed by a blog administrator.
ReplyDeleteHi,
ReplyDeleteI want to use webdriver for cross browser testing in linux , please help me out .
Please go to https://groups.google.com/forum/?fromgroups=#!forum/webdriver if you have questions about WebDriver.
ReplyDelete