Skip to content

Commit fc79624

Browse files
committed
Adding driver info into TimeoutException thrown by WebDriverWait. Fixes issue 7429
1 parent b9e9fc6 commit fc79624

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

.idea/copyright/profiles_settings.xml

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/client/src/org/openqa/selenium/support/ui/BUCK

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ java_library(name = 'wait',
4646
deps = [
4747
':clock',
4848
'//java/client/src/org/openqa/selenium:webdriver-api',
49+
'//java/client/src/org/openqa/selenium/remote:remote',
4950
'//third_party/java/guava-libraries:guava-libraries',
5051
],
5152
visibility = ['PUBLIC'],

java/client/src/org/openqa/selenium/support/ui/WebDriverWait.java

+21
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
package org.openqa.selenium.support.ui;
1818

1919
import org.openqa.selenium.NotFoundException;
20+
import org.openqa.selenium.TimeoutException;
2021
import org.openqa.selenium.WebDriver;
22+
import org.openqa.selenium.WebDriverException;
23+
import org.openqa.selenium.remote.RemoteWebDriver;
2124

2225
import java.util.concurrent.TimeUnit;
2326

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

3034
/**
3135
* Wait will ignore instances of NotFoundException that are encountered (thrown) by default in
@@ -67,5 +71,22 @@ protected WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long tim
6771
withTimeout(timeOutInSeconds, TimeUnit.SECONDS);
6872
pollingEvery(sleepTimeOut, TimeUnit.MILLISECONDS);
6973
ignoring(NotFoundException.class);
74+
this.driver = driver;
75+
}
76+
77+
@Override
78+
protected RuntimeException timeoutException(String message, Throwable lastException) {
79+
TimeoutException ex = new TimeoutException(message, lastException);
80+
ex.addInfo(WebDriverException.DRIVER_INFO, driver.getClass().getName());
81+
if (driver instanceof RemoteWebDriver) {
82+
RemoteWebDriver remote = (RemoteWebDriver) driver;
83+
if (remote.getSessionId() != null) {
84+
ex.addInfo(WebDriverException.SESSION_ID, remote.getSessionId().toString());
85+
}
86+
if (remote.getCapabilities() != null) {
87+
ex.addInfo("Capabilities", remote.getCapabilities().toString());
88+
}
89+
}
90+
throw ex;
7091
}
7192
}

java/client/src/org/openqa/selenium/support/ui/build.desc

+1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ java_library(name = "wait",
4949
deps = [
5050
":clock",
5151
"//java/client/src/org/openqa/selenium:webdriver-api",
52+
"//java/client/src/org/openqa/selenium/remote:remote",
5253
"//third_party/java/guava-libraries",
5354
])

0 commit comments

Comments
 (0)