I am upgrading to Selenium 3 which has broken a function I wrote a long while back that retrieves OS and browser information from the WebDriver
instance.
This used to get the browser version and OS name:
Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
String browserVersion = cap.getVersion();
String osName = cap.getPlatform().name().toLowerCase();
It no longer works. I get an empty string for the browser version and 'any' for the OS name. I am using a third party tool to manager the driver binaries:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.7.0</version>
</dependency>
This is how I create the driver instance:
FirefoxDriverManager.getInstance().setup();
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setCapability("acceptInsecureCerts", true);
WebDriver driver = new FirefoxDriver(caps);
WebDriver.Timeouts timeouts = driver.manage().timeouts();
timeouts.implicitlyWait(5L, TimeUnit.SECONDS);
driver.manage().window().maximize();
return driver;
This isn't much different from my Selenium 2 code. The only difference is the use of the driver manager from the 3rd party tool because using Firefox requires geckodriver now.