Thursday, November 1, 2012

Webdriver - Display Browser Version and Name

Webdriver - Display Browser Version and Name.

Tests are getting executed on different browsers, some time getting confused with the browser name and version of the test results, so I have implemented following code to make an entry in the log file.

  String script = "return navigator.appName;";
Temp = (String) ((JavascriptExecutor) driver).executeScript(script);
Print(Temp);
script = "return navigator.appVersion;";
Temp = (String) ((JavascriptExecutor) driver).executeScript(script);
Print(Temp);
  script = "return navigator.platform;";
  Print((String) ((JavascriptExecutor) driver).executeScript(script));

Print() is a user defined method created in our framework, to know more details select this link

---

No comments:

Post a Comment