How to use getSystemInformation method of org.openqa.selenium.WebDriverException class

Best Selenium code snippet using org.openqa.selenium.WebDriverException.getSystemInformation

WebDriverException org.openqa.selenium.WebDriverException

The WebDriver error - unknown error, happens when the driver tries to process a command and an unspecified error occurs.

The error can generally be isolated to the specific driver. It is a good practice to read the error message for any pointers on why the error occurred.

Example:

The error message shows that Selenium webdriver is not able to focus on element. generally, it happens due to incompatibility between Browser and Driver versions

copy
1Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot focus element 2 (Session info: chrome=61.0.3163.100) 3 (Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) 4Command duration or timeout: 0 milliseconds 5Build info: version: 'unknown', revision: 'unknown', time: 'unknown' 6System info: host: 'DWA7DEVOS00170', ip: '10.96.162.167', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_25' 7Driver info: org.openqa.selenium.chrome.ChromeDriver

Solutions:

  • Upgrade browser version
  • Upgrade driver version

Code Snippets

Here are code snippets that can help you understand more how developers are using

Source:WebDriverException.java Github

copy

Full Screen

...31 }32 private String createMessage(String originalMessageString) {33 return String.format("%sSystem info: %s\nDriver info: %s",34 originalMessageString == null ? "" : originalMessageString + "\n",35 getSystemInformation(),36 getDriverInformation());37 }38 public String getSystemInformation() {39 return String.format("os.name: '%s', os.arch: '%s', os.version: '%s', java.version: '%s'",40 System.getProperty("os.name"),41 System.getProperty("os.arch"),42 System.getProperty("os.version"),43 System.getProperty("java.version"));44 }45 public String getDriverInformation() {46 for (StackTraceElement e : getStackTrace()) {47 if (e.getClassName().startsWith("org.openqa.selenium")) {48 String[] bits = e.getClassName().split("\\.");49 if (bits.length > 3 && !"support".equals("bits")) {50 return "driver.version: " + bits[3];51 }52 }...

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1System.out.println(e.getSystemInformation());2System.out.println(e.getSupportUrl());3System.out.println(e.getBuildInformation());4System.out.println(e.getAdditionalInformation());5 (unknown error: DevToolsActivePort file doesn't exist)6 (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)7 (Driver info: chromedriver=2.35.528161 (7b8a81c2f2d2d4e4c4b8f4c3c3e3d3b3e3f3b3e3),platform=Linux 3.13.0-71-generic x86_64) (WARNING: The server did not provide any stacktrace information)

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.remote.RemoteWebDriver;4import java.net.URL;5public class GetSystemInformation {6 public static void main(String[] args) throws Exception {7 DesiredCapabilities capabilities = new DesiredCapabilities();8 capabilities.setCapability("browserName", "chrome");9 capabilities.setCapability("platform", "Windows 10");10 capabilities.setCapability("version", "latest");11 System.out.println(driver.getSystemInformation());12 driver.quit();13 }14}15import org.openqa.selenium.WebDriverException;16import org.openqa.selenium.remote.DesiredCapabilities;17import org.openqa.selenium.remote.RemoteWebDriver;18import java.net.URL;19public class GetSystemInformation {20 public static void main(String[] args) throws Exception {21 DesiredCapabilities capabilities = new DesiredCapabilities();22 capabilities.setCapability("browserName", "chrome");23 capabilities.setCapability("platform", "Windows 10");24 capabilities.setCapability("version", "latest");25 System.out.println(driver.getSystemInformation());26 driver.quit();27 }28}29from selenium import webdriver30from selenium.webdriver.common.desired_capabilities import DesiredCapabilities31import os32driver = webdriver.Remote(33print(driver.get_system_information())34driver.quit()35driver = Selenium::WebDriver.for(

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1package com.automationrhapsody.selenium;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebDriverException;4import org.openqa.selenium.chrome.ChromeDriver;5public class GetSystemInformation {6 public static void main(String[] args) {7 WebDriver driver = new ChromeDriver();8 try {9 } catch (WebDriverException e) {10 System.out.println(e.getSystemInformation());11 } finally {12 driver.quit();13 }14 }15}16 (unknown error: DevToolsActivePort file doesn't exist)17 (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)18 (Driver info: chromedriver=2.43.600233 (3f0c0d3a3f3dcd039f842dc88e9c601b2b4836f9),platform=Linux 4.15.0-58-generic x86_64)19 (unknown error: DevToolsActivePort file doesn't exist)20 (The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)21 (Driver info: chromedriver=2.43.600233 (3f0c0d3a3f3dcd039f842dc88e9c601b2b4836f9),platform=Windows NT 6.1.7601 SP1 x86_64)22 (unknown error: DevToolsActivePort file doesn't exist)23 (The process started from chrome location /Applications/Google Chrome.app/Contents/MacOS/Google Chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)24 (Driver info: chromedriver=2.43.600233 (3f0c0d3a3f3dcd039f842dc88e9c

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1public class GetSystemInformation {2public static void main(String[] args) {3WebDriver driver = new FirefoxDriver();4System.out.println("Successfully opened the website www.Store.Demoqa.com");5WebElement myAccount = driver.findElement(By.id("account"));6WebElement userName = driver.findElement(By.id("log"));7WebElement passWord = driver.findElement(By.id("pwd"));8WebElement login = driver.findElement(By.id("login"));9WebElement logOut = driver.findElement(By.id("account_logout"));10System.out.println("Successfully found the element: " + logOut.toString());11WebDriverException wde = new WebDriverException();12System.out.println(wde.getSystemInformation());13driver.quit();14}15}16Successfully found the element: org.openqa.selenium.WebElement: {Using=id, value=account_logout}17org.openqa.selenium.WebDriverException: Unable to locate element: {"method":"id","selector":"account_logout"}

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1package com.automationrhapsody.selenium;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebDriverException;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6public class GetSystemInformationExample {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");9 ChromeOptions options = new ChromeOptions();10 options.addArguments("--headless");11 WebDriver driver = new ChromeDriver(options);12 try {13 } catch (WebDriverException e) {14 System.out.println(e.getSystemInformation());15 } finally {16 driver.quit();17 }18 }19}20* Driver : ChromeDriver 2.38.552518 (f68bf1d2c0f7c7b8d8e1c7a0b1a9c1b86e9d7b0a)21* Driver version : ChromeDriver 2.38.552518 (f68bf1d2c0f7c7b8d8e1c7a0b1a9c1b86e9d7b0a)

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException;2public class WebDriverExceptionGetSystemInformation {3 public static void main(String[] args) {4 WebDriverException webDriverException = new WebDriverException("WebDriverException");5 System.out.println(webDriverException.getSystemInformation());6 }7}

Full Screen

Full Screen

getSystemInformation

Using AI Code Generation

copy

Full Screen

1package com.qtpselenium.core.ddf.testcases;2import java.net.URL;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.remote.DesiredCapabilities;5import org.openqa.selenium.remote.RemoteWebDriver;6import org.testng.annotations.Test;7public class SystemInformationTest {8 public void testSystemInformation() throws Exception{9 DesiredCapabilities cap = DesiredCapabilities.firefox();10 String sysInfo = ((RemoteWebDriver)driver).getSystemInformation();11 System.out.println(sysInfo);12 driver.quit();13 }14}

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful