Selenium Webdriver Scripts : how to get browser name and version using selenium webdriver


package selenium_examples;


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Test {

public static void main(String[] args) {


WebDriver driver = new FirefoxDriver();
driver.get("http://www.funandknowledge.blogspot.com");
Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();

String browserName = cap.getBrowserName().toLowerCase();
System.out.println(browserName);

String version = cap.getVersion().toString();
System.out.println(version);


}
}



Output :-

firefox
19.0

No comments:

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge