Thursday 3 October 2013

Getting Browser details using Selenium web driver 2.0

Browser capabilities:
Getting Browser details in selenium is quite easy. Using this we can run our scripts across various machines, various OS, and various browsers (It will be explained in Selenium Grid concept).

Include these two packages into your script
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.Capabilities;


Add the snippet in your script.
Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
String browserName = cap.getBrowserName().toLowerCase();
System.out.println(browserName);
String os = cap.getPlatform().toString();
System.out.println(os);
String v = cap.getVersion().toString();
System.out.println(v);

No comments:

Post a Comment

Angular JS Protractor Installation process - Tutorial Part 1

                     Protractor, formally known as E2E testing framework, is an open source functional automation framework designed spe...