Skip to content

Commit

Permalink
Adding driver info into TimeoutException thrown by WebDriverWait. Fix…
Browse files Browse the repository at this point in the history
…es issue 7429
  • Loading branch information
barancev committed Jun 6, 2014
1 parent b9e9fc6 commit fc79624
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/support/ui/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ java_library(name = 'wait',
deps = [
':clock',
'//java/client/src/org/openqa/selenium:webdriver-api',
'//java/client/src/org/openqa/selenium/remote:remote',
'//third_party/java/guava-libraries:guava-libraries',
],
visibility = ['PUBLIC'],
Expand Down
21 changes: 21 additions & 0 deletions java/client/src/org/openqa/selenium/support/ui/WebDriverWait.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
package org.openqa.selenium.support.ui;

import org.openqa.selenium.NotFoundException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.util.concurrent.TimeUnit;

Expand All @@ -26,6 +29,7 @@
*/
public class WebDriverWait extends FluentWait<WebDriver> {
public final static long DEFAULT_SLEEP_TIMEOUT = 500;
private final WebDriver driver;

/**
* Wait will ignore instances of NotFoundException that are encountered (thrown) by default in
Expand Down Expand Up @@ -67,5 +71,22 @@ protected WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long tim
withTimeout(timeOutInSeconds, TimeUnit.SECONDS);
pollingEvery(sleepTimeOut, TimeUnit.MILLISECONDS);
ignoring(NotFoundException.class);
this.driver = driver;
}

@Override
protected RuntimeException timeoutException(String message, Throwable lastException) {
TimeoutException ex = new TimeoutException(message, lastException);
ex.addInfo(WebDriverException.DRIVER_INFO, driver.getClass().getName());
if (driver instanceof RemoteWebDriver) {
RemoteWebDriver remote = (RemoteWebDriver) driver;
if (remote.getSessionId() != null) {
ex.addInfo(WebDriverException.SESSION_ID, remote.getSessionId().toString());
}
if (remote.getCapabilities() != null) {
ex.addInfo("Capabilities", remote.getCapabilities().toString());
}
}
throw ex;
}
}
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/support/ui/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ java_library(name = "wait",
deps = [
":clock",
"//java/client/src/org/openqa/selenium:webdriver-api",
"//java/client/src/org/openqa/selenium/remote:remote",
"//third_party/java/guava-libraries",
])

0 comments on commit fc79624

Please sign in to comment.