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

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

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

copy

Full Screen

...156 Log4jLogger.info("Element is visible");157 } catch (ElementNotVisibleException enve) {158 // Log and throw the ElementNotVisibleException159 Log4jLogger.error(enve.getMessage());160 Log4jLogger.error(enve.getAdditionalInformation());161 throw enve;162 } catch (ElementNotFoundException enfe) {163 // Log and throw the ElementNotFoundException164 Log4jLogger.error(enfe.getMessage());165 Log4jLogger.error(enfe.getElementName());166 throw enfe;167 } catch (Exception ex) {168 Log4jLogger.error(ex.getMessage());169 throw ex;170 }171 }172 173 /*174 * Get Web element having dynamic Xpath175 */176 public WebElement getWebElementWithDynamicXpath(String xpathToBeModified, String dynamicVariable) {177 // Declare modified xpath178 String modifiedXpath;179 // Replace dynamic variable(s)180 modifiedXpath = xpathToBeModified.replaceFirst("DYNAMIC_LOCATOR_VARIABLE", dynamicVariable);181 // Wait for webelement to be visible182 try {183 WebDriverWait wait = new WebDriverWait(driver,90);184 wait.until(ExpectedConditions.elementToBeClickable(By.xpath(modifiedXpath)));185 Log4jLogger.info("Element is visible");186 // return webelement with dynamic xpath187 return driver.findElement(By.xpath(modifiedXpath));188 } catch (ElementNotVisibleException enve) {189 // Log and throw the ElementNotVisibleException190 Log4jLogger.error(enve.getMessage());191 Log4jLogger.error(enve.getAdditionalInformation());192 throw enve;193 } catch (ElementNotFoundException enfe) {194 // Log and throw the ElementNotFoundException195 Log4jLogger.error(enfe.getMessage());196 Log4jLogger.error(enfe.getElementName());197 throw enfe;198 } catch (Exception ex) {199 Log4jLogger.error(ex.getMessage());200 throw ex;201 }202 }203 204 /*205 * Wait for web page to load206 */207 public void waitForPageToLoad() {208 // BasePageObjects basePageObjects = new BasePageObjects();209 Log4jLogger.info("Wait for page to load");210 try {211 // Wait for page to load212 ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {213 public Boolean apply(WebDriver driver) {214 return ((JavascriptExecutor) driver).executeScript("return document.readyState").toString()215 .equals("complete");216 }217 };218 WebDriverWait wait = new WebDriverWait(driver, 60);219 wait.until(expectation);220 } catch (Throwable error) {221 // Log the error222 Log4jLogger.error(error.getMessage());223 }224 }225 226 /*227 * Perform click on checkbox228 */229 public void checkboxCheck(WebElement checkBox) throws Exception {230 // BasePageObjects basePageObjects = new BasePageObjects();231 Log4jLogger.info("Check the checkbox = " + checkBox);232 // Wait for checkbox to be enabled233 waitForElementClickability(checkBox);234 // Check the checkbox if it is currently unchecked. Do nothing if it is235 // already checked236 if (!checkBox.isSelected()) {237 checkBox.click();238 Log4jLogger.info("Checkbox = " + checkBox + " is checked");239 } else {240 Log4jLogger.info("Checkbox = " + checkBox + " is already checked");241 }242 // Check that checkbox is checked or not243 if (!checkBox.isSelected()) {244 // Checkbox is not checked245 Log4jLogger.error("Chechkbox = " + checkBox + " is not checked");246 throw new Exception("Chechkbox = " + checkBox + " is not checked");247 }248 }249 250 /*251 * Wait for element ot be clickable252 */253 public void waitForElementClickability(WebElement elemToWaitForClickability) throws Exception {254 // Wait for the element to be clickable in the given time in seconds255 // BasePageObjects basePageObjects = new BasePageObjects();256 // Extract the Locator from WebElement257 String locator = null;258 if ((elemToWaitForClickability instanceof WebElement)) {259 Object elemToWaitForClickabilityObject = elemToWaitForClickability;260 String textOfElemToWaitForClickability = elemToWaitForClickabilityObject.toString();261 /*262 * This will split text and get that locator of Element text is263 * something like this [[FirefoxDriver: firefox on WINDOWS264 * (9170d4a5-1554-4018-adac-f3f6385370c0)] -> xpath:265 * //div[contains(@266 * class,'forum-topic-preview')]//div[contains(@class,'small-human')267 * ]]268 */269 String[] arrayTextOfElemToWaitForClickability = textOfElemToWaitForClickability.split(":");270 String[] locatorType = arrayTextOfElemToWaitForClickability[1].split(" ");271 for (int i = 0; i < arrayTextOfElemToWaitForClickability.length; i++) {272 if (i == 0 || i == 1) {273 textOfElemToWaitForClickability = "";274 } else {275 textOfElemToWaitForClickability = textOfElemToWaitForClickability276 + arrayTextOfElemToWaitForClickability[i];277 }278 }279 locator = locatorType[locatorType.length - 1] + " = ";280 locator = locator + textOfElemToWaitForClickability;281 }282 283 try {284 WebDriverWait wait = new WebDriverWait(driver, 30);285 wait.until(ExpectedConditions.elementToBeClickable(elemToWaitForClickability));286 Log4jLogger.info("Element is clickable");287 } catch (WebDriverException enve) {288 // Log and throw the WebDriverException289 Log4jLogger.error(enve.getAdditionalInformation());290 throw enve;291 } catch (ElementNotFoundException enfe) {292 // Log and throw the ElementNotFoundException293 Log4jLogger.error(enfe.getMessage());294 Log4jLogger.error(enfe.getElementName());295 throw enfe;296 } catch (Exception ex) {297 Log4jLogger.error(ex.getMessage());298 throw ex;299 }300 }301 302 /*303 * get count of elements in web page using xpath...

Full Screen

Full Screen

Source:IntegrationTestHelper.java Github

copy

Full Screen

...38 driver.manage().window().setSize(new Dimension(1280, 1024));39 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);40 } catch (WebDriverException e) {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 }...

Full Screen

Full Screen

Source:WebDriverException.java Github

copy

Full Screen

...48 return (originalMessageString == null ? "" : originalMessageString + "\n")49 + supportMessage50 + getBuildInformation() + "\n"51 + getSystemInformation()52 + getAdditionalInformation();53 }54 public String getSystemInformation() {55 return String.format("System info: host: '%s', ip: '%s', os.name: '%s', os.arch: '%s', os.version: '%s', java.version: '%s'",56 HOST_NAME,57 HOST_ADDRESS,58 System.getProperty("os.name"),59 System.getProperty("os.arch"),60 System.getProperty("os.version"),61 System.getProperty("java.version"));62 }63 public String getSupportUrl() {64 return null;65 }66 public BuildInfo getBuildInformation() {67 return new BuildInfo();68 }69 public static String getDriverName(StackTraceElement[] stackTraceElements) {70 String driverName = "unknown";71 for (StackTraceElement e : stackTraceElements) {72 if (e.getClassName().endsWith("Driver")) {73 String[] bits = e.getClassName().split("\\.");74 driverName = bits[bits.length - 1];75 }76 }77 return driverName;78 }79 public void addInfo(String key, String value) {80 extraInfo.put(key, value);81 }82 public String getAdditionalInformation() {83 if (!extraInfo.containsKey(DRIVER_INFO)) {84 extraInfo.put(DRIVER_INFO, "driver.version: " + getDriverName(getStackTrace()));85 }86 String result = "";87 for (Map.Entry<String, String> entry : extraInfo.entrySet()) {88 if (entry.getValue() != null && entry.getValue().startsWith(entry.getKey())) {89 result += "\n" + entry.getValue();90 } else {91 result += "\n" + entry.getKey() + ": " + entry.getValue();92 }93 }94 return result;95 }96}...

Full Screen

Full Screen

Source:LogTest.java Github

copy

Full Screen

...59 log.info("Description" + note);60 }catch (NoSuchElementException ne){61 log.error("webelement not found: " + ne.getMessage());62 }catch (WebDriverException we){63 log.error("webdriver failed: " + we.getAdditionalInformation());64 }catch (Exception ex){65 log.fatal(ex.getMessage());66 }67 }68}...

Full Screen

Full Screen

Source:FalabellaPrincipal.java Github

copy

Full Screen

...49 log.info("Tiempo de espera 5 segundos");50 } catch (NoSuchElementException ne){51 System.out.println("WebElement no encontrado: " + ne.getMessage());52 } catch (WebDriverException we){53 System.out.println("WebElement fallo: " + we.getAdditionalInformation());54 } catch (Exception ex){55 System.out.println(ex.getMessage());56 }57 }5859} ...

Full Screen

Full Screen

Source:Google.java Github

copy

Full Screen

...43 log.info("Tiempo de espera 3 segundos");44 } catch (NoSuchElementException ne){45 System.out.println("WebElement no encontrado: " + ne.getMessage());46 } catch (WebDriverException we){47 System.out.println("WebElement fallo: " + we.getAdditionalInformation());48 } catch (Exception ex){49 System.out.println(ex.getMessage());50 }5152 }53} ...

Full Screen

Full Screen

Source:AutomationErrors.java Github

copy

Full Screen

...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

Source:CucumberTestContext.java Github

copy

Full Screen

...20 if (driver != null) {21 try {22 driver.quit();23 } catch (WebDriverException wde) {24 LOG.warn("Exception caught calling controller.quit(): \"" + wde.getMessage() + "\" additional info: " + wde.getAdditionalInformation());25 }26 }27 driver = null;28 }29 }30 /**31 * The inner context as a thread local variable.32 */33 private static ThreadLocal<Context> innerContext = new ThreadLocal<CucumberTestContext.Context>() {34 @Override35 protected Context initialValue() {36 return new Context(); //initial is empty;37 }38 };...

Full Screen

Full Screen

getAdditionalInformation

Using AI Code Generation

copy

Full Screen

1package com.mkyong.core;2import org.openqa.selenium.By;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.firefox.FirefoxDriver;6import org.openqa.selenium.firefox.FirefoxProfile;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.openqa.selenium.remote.RemoteWebDriver;9import org.openqa.selenium.remote.SessionNotFoundException;10import org.openqa.selenium.support.ui.ExpectedCondition;11import org.openqa.selenium.support.ui.WebDriverWait;12public class WebDriverExceptionExample {13public static void main(String[] args) {14System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");15FirefoxProfile profile = new FirefoxProfile();16profile.setPreference("network.proxy.type", 0);17DesiredCapabilities capabilities = DesiredCapabilities.firefox();18capabilities.setCapability("marionette", true);19capabilities.setCapability(FirefoxDriver.PROFILE, profile);20WebDriver driver = new FirefoxDriver(capabilities);21WebElement element = driver.findElement(By.name("q"));22element.sendKeys("mkyong.com");23element.submit();24(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {25public Boolean apply(WebDriver d) {26return d.getTitle().toLowerCase().startsWith("mkyong.com");27}28});29System.out.println("Page title is: " + driver.getTitle());30driver.quit();31}32}

Full Screen

Full Screen

getAdditionalInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException;2import org.openqa.selenium.remote.RemoteWebDriver;3import org.openqa.selenium.remote.Response;4public class GetAdditionalInformation {5 public static void main(String[] args) {6 try {7 } catch (WebDriverException e) {8 Response response = e.getAdditionalInformation();9 System.out.println(response);10 }11 }12}13{status=13, value={error=unknown error, message=An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.apple.iphonesimulator.Simulator' simulator. Original error: Error: Command failed: xcrun simctl list --json devices14 at ChildProcess.exithandler (child_process.js:303:12)15 at emitTwo (events.js:126:13)16 at ChildProcess.emit (events.js:214:7)17 at maybeClose (internal/child_process.js:925:16)18 at Socket.stream.socket.on (internal/child_process.js:346:11)19 at emitOne (events.js:116:13)20 at Socket.emit (events.js:211:7)21 at Pipe._handle.close [as _onclose] (net.js:557:12), stacktrace=org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.apple.iphonesimulator.Simulator' simulator. Original error: Error: Command failed: xcrun simctl list --json devices22 at ChildProcess.exithandler (child_process.js:303:12)23 at emitTwo (events.js:126:13)24 at ChildProcess.emit (events.js:214:7)25 at maybeClose (internal/child_process.js:925:16)26 at Socket.stream.socket.on (internal/child_process.js:346:11)27 at emitOne (events.js:116:13)28 at Socket.emit (events.js:211:7)29 at Pipe._handle.close [as _onclose] (

Full Screen

Full Screen

getAdditionalInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException;2import org.openqa.selenium.remote.RemoteWebDriver;3import org.openqa.selenium.remote.RemoteWebElement;4RemoteWebElement element = (RemoteWebElement) driver.findElement(By.id("lst-ib"));5try {6 element.sendKeys("webdriver");7} catch (WebDriverException e) {8 System.out.println(e.getAdditionalInformation());9}10driver.quit();11org.openqa.selenium.WebDriverException: unknown error: Element <input id="lst-ib" class="gsfi" maxlength="2048" name="q" title="Search" value="" autocomplete="off" autocapitalize="off" spellcheck="false" dir="ltr" style="outline: none;" tabindex="1" aria-haspopup="false" role="combobox" aria-autocomplete="both" aria-expanded="false"> is not clickable at point (509, 9). Other element would receive the click: <div id="gb" class="gbh" role="banner">...</div>12 (Session info: chrome=54.0.2840.71)13 (Driver info: chromedriver=2.21.371459 (2f1d9a9cbf6e2e6a0f3c3c6b7d3c3f3d1e2d1f2e),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)14Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={userDataDir=/

Full Screen

Full Screen

getAdditionalInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException;2import org.openqa.selenium.remote.Response;3import org.openqa.selenium.remote.http.HttpResponse;4public class GetAdditionalInformation {5 public static void main(String[] args) {6 Response response = new Response();7 response.setStatus(500);8 response.setValue("Something went wrong");9 WebDriverException exception = new WebDriverException("Error", response, HttpResponse::new);10 System.out.println(exception.getAdditionalInformation());11 }12}13{14 "org.openqa.selenium.remote.http.HttpResponse.<init>(HttpResponse.java:46)",15 "org.openqa.selenium.remote.Response.createException(Response.java:180)",16 "org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:122)",17 "org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:110)",18 "org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)",19 "org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)",20 "org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)",21 "org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)",22 "org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)",23 "GetAdditionalInformation.main(GetAdditionalInformation.java:19)"24 "value": {25 "stacktrace": "org.openqa.selenium.remote.http.HttpResponse.<init>(HttpResponse.java:46)26org.openqa.selenium.remote.Response.createException(Response.java:180)27org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:122)28org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:110)29org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)30org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)31org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)32org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)33org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)34GetAdditionalInformation.main(GetAdditionalInformation.java:19)"35 }36}

Full Screen

Full Screen

getAdditionalInformation

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriverException2try {3 driver.findElement(By.name("q")).sendKeys("Selenium")4 driver.findElement(By.name("q")).submit()5 driver.findElement(By.linkText("Selenium - Web Browser Automation")).click()6} catch (WebDriverException e) {7 println e.getAdditionalInformation()8}9 (Session info: chrome=83.0.4103.97)10import org.openqa.selenium.WebDriverException11try {12 driver.findElement(By.name("q")).sendKeys("Selenium")13 driver.findElement(By.name("q")).submit()14 driver.findElement(By.linkText("Selenium - Web Browser Automation")).click()15} catch (WebDriverException e) {16 println e.getMessage()17}18 (Session info: chrome=83.0.4103.97)19import org.openqa.selenium.WebDriverException20try {21 driver.findElement(By.name("q")).sendKeys("Selenium")22 driver.findElement(By.name("q")).submit()23 driver.findElement(By.linkText("Selenium - Web Browser Automation")).click()24} catch (WebDriverException e) {25 println e.getStackTrace()26}27 (Session info: chrome=83.0.4103.97)28 at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$15(ExpectedConditions.java:906)29 at org.openqa.selenium.support.ui.ExpectedConditions$$Lambda$119/0x0000000840b0c440.apply(Unknown Source)30 at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)

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