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

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

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:IntegrationTestHelper.java Github

copy

Full Screen

...41 System.err.println("Message - " + e.getMessage());42 System.err.println("Additional info - " + e.getAdditionalInformation());43 System.err.println("Support url - " + e.getSupportUrl());44 System.err.println("System info - " + e.getSystemInformation());45 System.err.println("Build info - " + e.getBuildInformation());46 throw e;47 } catch (Throwable t) {48 System.err.println("Class - " + t.getClass());49 System.err.println("Message - " + t.getMessage());50 System.err.println("--------");51 t.printStackTrace(System.err);52 System.err.println("--------");53 throw t;54 }55 return driver;56 }57 public static void takeScreenshot(WebDriver browser, String screenshotName) {58 if (browser instanceof TakesScreenshot) {59 String testCaseClass = calledByClass();...

Full Screen

Full Screen

Source:WebDriverException.java Github

copy

Full Screen

...35 "" : "For documentation on this error, please visit: " + getSupportUrl() + "\n";36 return String.format("%s%s%s\nSystem info: %s\nDriver info: %s",37 originalMessageString == null ? "" : originalMessageString + "\n",38 supportMessage,39 getBuildInformation(),40 getSystemInformation(),41 getDriverInformation());42 }43 public String getSystemInformation() {44 return String.format("os.name: '%s', os.arch: '%s', os.version: '%s', java.version: '%s'",45 System.getProperty("os.name"),46 System.getProperty("os.arch"),47 System.getProperty("os.version"),48 System.getProperty("java.version"));49 }50 public String getSupportUrl() {51 return null;52 }53 public BuildInfo getBuildInformation() {54 return new BuildInfo();55 }56 public String getDriverInformation() {57 String driverInformation = "driver.version: " + getDriverName(getStackTrace());58 if (sessionId != null) {59 driverInformation += "\nSession ID: " + sessionId;60 }61 return driverInformation;62 }63 public void setSessionId(String sessionId) {64 this.sessionId = sessionId;65 }66 public static String getDriverName(StackTraceElement[] stackTraceElements) {67 String driverName = "unknown";...

Full Screen

Full Screen

Source:AutomationErrors.java Github

copy

Full Screen

...57 return new StringBuilder()58 .append((originalMessageString == null) ? ""59 : new StringBuilder().append(originalMessageString)60 .append("\n").toString()).toString();61 /*.append(supportMessage).append(getBuildInformation())62 .append("\n").append(getSystemInformation())63 .append(getAdditionalInformation()).toString();*/64 }65 66}...

Full Screen

Full Screen

getBuildInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException;2import org.openqa.selenium.remote.RemoteWebDriver;3import java.util.Map;4import java.util.HashMap;5import java.util.Set;6import java.util.Iterator;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.openqa.selenium.remote.RemoteWebDriver;9import org.openqa.selenium.remote.RemoteWebElement;10import org.openqa.selenium.remote.Augmenter;11import org.openqa.selenium.remote.CapabilityType;12import org.openqa.selenium.remote.DesiredCapabilities;13import org.openqa.selenium.remote.DriverCommand;14import org.openqa.selenium.remote.ErrorHandler;15import org.openqa.selenium.remote.HttpCommandExecutor;16import org.openqa.selenium.remote.HttpCommandExecutor;17import org.openqa.selenium.remote.Response;18import org.openqa.selenium.remote.RemoteWebDriver;19import org.openqa.selenium.remote.RemoteWebElement;20import org.openqa.selenium.remote.Augmenter;21import org.openqa.selenium.remote.CapabilityType;22import org.openqa.selenium.remote.DesiredCapabilities;23import org.openqa.selenium.remote.DriverCommand;24import org.openqa.selenium.remote.ErrorHandler;25import org.openqa.selenium.remote.HttpCommandExecutor;26import org.openqa.selenium.remote.HttpCommandExecutor;27import org.openqa.selenium.remote.Response;28import org.openqa.selenium.remote.RemoteWebDriver;29import org.openqa.selenium.remote.RemoteWebElement;30import org.openqa.selenium.remote.Augmenter;31import org.openqa.selenium.remote.CapabilityType;32import org.openqa.selenium.remote.DesiredCapabilities;33import org.openqa.selenium.remote.DriverCommand;34import org.openqa.selenium.remote.ErrorHandler;35import org.openqa.selenium.remote.HttpCommandExecutor;36import org.openqa.selenium.remote.HttpCommandExecutor;37import org.openqa.selenium.remote.Response;38import org.openqa.selenium.remote.RemoteWebDriver;39import org.openqa.selenium.remote.RemoteWebElement;40import org.openqa.selenium.remote.Augmenter;41import org.openqa.selenium.remote.CapabilityType;42import org.openqa.selenium.remote.DesiredCapabilities;43import org.openqa.selenium.remote.DriverCommand;44import org.openqa.selenium.remote.ErrorHandler;45import org.openqa.selenium.remote.HttpCommandExecutor;46import org.openqa.selenium.remote.HttpCommandExecutor;47import org.openqa.selenium.remote.Response;48import org.openqa.selenium.remote.RemoteWebDriver;49import org.openqa.selenium.remote.RemoteWebElement;50import org.openqa.selenium.remote.Augmenter;51import org.openqa.selenium.remote.CapabilityType;52import org.openqa.selenium.remote.DesiredCapabilities;53import org.openqa.selenium.remote.DriverCommand;54import org.openqa.selenium.remote.ErrorHandler;55import org.openqa.selenium.remote.HttpCommandExecutor;56import org.openqa.selenium.remote.HttpCommandExecutor;57import org.openqa.selenium.remote.Response;58import org.openqa.selenium.remote.RemoteWebDriver;59import org.openqa.selenium.remote.RemoteWebElement;60import org.openqa.selenium.remote.Augmenter;61import org.openqa

Full Screen

Full Screen

getBuildInformation

Using AI Code Generation

copy

Full Screen

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

Full Screen

Full Screen

getBuildInformation

Using AI Code Generation

copy

Full Screen

1package com.selenium2.easy.test.server.automation;2import java.util.Date;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebDriverException;5import org.openqa.selenium.firefox.FirefoxDriver;6public class WebDriverExceptionExample {7 public static void main(String[] args) {8 WebDriver driver = new FirefoxDriver();9 try {10 System.out.println("Page title is: " + driver.getTitle());11 System.out.println("Before exception");12 throw new WebDriverException("This is a custom exception");13 } catch (WebDriverException e) {14 System.out.println("Exception occurred");15 System.out.println("Exception message is: " + e.getMessage());16 System.out.println("Exception build information is: " + e.getBuildInformation());17 System.out.println("Exception class is: " + e.getClass());18 System.out.println("Exception stack trace is: " + e.getStackTrace());19 System.out.println("Exception cause is: " + e.getCause());20 System.out.println("Exception localized message is: " + e.getLocalizedMessage());21 System.out.println("Exception date is: " + new Date());22 }23 }24}25Exception stack trace is: [Ljava.lang.StackTraceElement;@5d7e1d7726In this example, we are throwing an exception manually using throw keyword. We are using getBuildInformation() method of WebDriverException class to get the build information of the exception. The output of the above code is as follows:27Exception stack trace is: [Ljava.lang.StackTraceElement;@5d7e1d77

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