We can get the browser name, version and operating system name and version with the following commands in selenium RC.
Below code is tested in Mozilla Firefox
Browser Name
Below code is tested in Mozilla Firefox
Browser Name
System.out.println(selenium.getEval("navigator.appCodeName;"));
Mozilla
Browser version
System.out.println(selenium.getEval("navigator.appVersion;"));
5.0 (Windows; en-US)
Browser and Operating system detail
System.out.println(selenium.getEval("navigator.userAgent;"));
Result.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)
String browser = selenium.getEval("navigator.userAgent");
if (browser.contains("Firefox") || browser.contains("Chrome")) {
No comments:
Post a Comment