@@ -40,7 +40,7 @@ public boolean waitFor(BooleanSupplier condition, Duration timeout, Duration pol
40
40
@ Override
41
41
public void waitForTrue (BooleanSupplier condition , Duration timeout , Duration pollingInterval , String message , Collection <Class <? extends Throwable >> exceptionsToIgnore ) throws TimeoutException {
42
42
BooleanSupplier supplier = Optional .ofNullable (condition ).orElseThrow (() -> new IllegalArgumentException ("Condition cannot be null" ));
43
- long timeoutInSeconds = resolveConditionTimeoutInSeconds (timeout );
43
+ Duration currentTimeout = resolveConditionTimeout (timeout );
44
44
long pollingIntervalInMilliseconds = resolvePollingInterval (pollingInterval ).toMillis ();
45
45
String exMessage = resolveMessage (message );
46
46
double startTime = getCurrentTime ();
@@ -50,8 +50,8 @@ public void waitForTrue(BooleanSupplier condition, Duration timeout, Duration po
50
50
}
51
51
52
52
double currentTime = getCurrentTime ();
53
- if ((currentTime - startTime ) > timeoutInSeconds ) {
54
- String exceptionMessage = String .format ("Timed out after %1$s seconds during wait for condition '%2$s'" , timeoutInSeconds , exMessage );
53
+ if ((currentTime - startTime ) > currentTimeout . getSeconds () ) {
54
+ String exceptionMessage = String .format ("Timed out after %1$s seconds during wait for condition '%2$s'" , currentTimeout , exMessage );
55
55
throw new TimeoutException (exceptionMessage );
56
56
}
57
57
@@ -67,10 +67,10 @@ public void waitForTrue(BooleanSupplier condition, Duration timeout, Duration po
67
67
public <T > T waitFor (ExpectedCondition <T > condition , Duration timeout , Duration pollingInterval , String message , Collection <Class <? extends Throwable >> exceptionsToIgnore ) {
68
68
IApplication app = applicationProvider .get ();
69
69
app .setImplicitWaitTimeout (Duration .ZERO );
70
- long timeoutInSeconds = resolveConditionTimeoutInSeconds (timeout );
70
+ Duration currentTimeout = resolveConditionTimeout (timeout );
71
71
Duration actualPollingInterval = resolvePollingInterval (pollingInterval );
72
72
String exMessage = resolveMessage (message );
73
- WebDriverWait wait = new WebDriverWait (app .getDriver (), timeoutInSeconds );
73
+ WebDriverWait wait = new WebDriverWait (app .getDriver (), currentTimeout );
74
74
wait .pollingEvery (actualPollingInterval );
75
75
wait .withMessage (exMessage );
76
76
wait .ignoreAll (exceptionsToIgnore == null ? Collections .singleton (StaleElementReferenceException .class ) : exceptionsToIgnore );
@@ -97,8 +97,8 @@ private boolean isConditionSatisfied(BooleanSupplier condition, Collection<Class
97
97
}
98
98
}
99
99
100
- private long resolveConditionTimeoutInSeconds (Duration timeout ) {
101
- return Optional .ofNullable (timeout ).orElse (timeoutConfiguration .getCondition ()). getSeconds () ;
100
+ private Duration resolveConditionTimeout (Duration timeout ) {
101
+ return Optional .ofNullable (timeout ).orElse (timeoutConfiguration .getCondition ());
102
102
}
103
103
104
104
private Duration resolvePollingInterval (Duration pollingInterval ) {
0 commit comments