7

What I want to do is, while I'm running my tests, I want to get the current,

  1. Operating System
  2. Browser Name
  3. Browser Version

This is for making the details clear in the test/bug report. I haven't tried any solution yet as I'm new to Selenium and am not aware if it can be done.

1 Answer 1

7

Yes is possible using Selenium with the "Capabilities" class.

Here is sample code you can use to get the details you need:

Capabilities caps = ((RemoteWebDriver) driver).getCapabilities();
String browserName = caps.getBrowserName().toLowerCase();
String OS = caps.getPlatform().toString();
String BV = caps.getVersion().toString();
System.out.println("OS: " + OS + ", Browser: " + browserName + " V " + BV);
1
  • Wow! that was simple. This helps a lot. Sep 8, 2022 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.