|
17 | 17 | package org.openqa.selenium.support.ui;
|
18 | 18 |
|
19 | 19 | import org.openqa.selenium.NotFoundException;
|
| 20 | +import org.openqa.selenium.TimeoutException; |
20 | 21 | import org.openqa.selenium.WebDriver;
|
| 22 | +import org.openqa.selenium.WebDriverException; |
| 23 | +import org.openqa.selenium.remote.RemoteWebDriver; |
21 | 24 |
|
22 | 25 | import java.util.concurrent.TimeUnit;
|
23 | 26 |
|
|
26 | 29 | */
|
27 | 30 | public class WebDriverWait extends FluentWait<WebDriver> {
|
28 | 31 | public final static long DEFAULT_SLEEP_TIMEOUT = 500;
|
| 32 | + private final WebDriver driver; |
29 | 33 |
|
30 | 34 | /**
|
31 | 35 | * 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
|
67 | 71 | withTimeout(timeOutInSeconds, TimeUnit.SECONDS);
|
68 | 72 | pollingEvery(sleepTimeOut, TimeUnit.MILLISECONDS);
|
69 | 73 | 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; |
70 | 91 | }
|
71 | 92 | }
|
0 commit comments