3030import java .util .function .Function ;
3131import java .util .function .Supplier ;
3232
33- import static java .util .concurrent .TimeUnit .MILLISECONDS ;
34- import static java .util .concurrent .TimeUnit .SECONDS ;
35-
3633public class AppiumFluentWait <T > extends FluentWait <T > {
3734 private Function <IterationInfo , Duration > pollingStrategy = null ;
3835
@@ -198,7 +195,8 @@ protected T getInput() {
198195 *
199196 * @param pollingStrategy Function instance, where the first parameter
200197 * is the information about the current loop iteration (see {@link IterationInfo})
201- * and the expected result is the calculated interval
198+ * and the expected result is the calculated interval. It is highly
199+ * recommended that the value returned by this lambda is greater than zero.
202200 * @return A self reference.
203201 */
204202 public AppiumFluentWait <T > withPollingStrategy (Function <IterationInfo , Duration > pollingStrategy ) {
@@ -226,7 +224,7 @@ public AppiumFluentWait<T> withPollingStrategy(Function<IterationInfo, Duration>
226224 @ Override
227225 public <V > V until (Function <? super T , V > isTrue ) {
228226 final long start = getClock ().now ();
229- final long end = getClock ().laterBy (getTimeout ().in (MILLISECONDS ));
227+ final long end = getClock ().laterBy (getTimeout ().in (TimeUnit . MILLISECONDS ));
230228 long iterationNumber = 1 ;
231229 Throwable lastException ;
232230 while (true ) {
@@ -252,7 +250,7 @@ public <V> V until(Function<? super T, V> isTrue) {
252250 String timeoutMessage = String .format (
253251 "Expected condition failed: %s (tried for %d second(s) with %s interval)" ,
254252 message == null ? "waiting for " + isTrue : message ,
255- getTimeout ().in (SECONDS ), getInterval ());
253+ getTimeout ().in (TimeUnit . SECONDS ), getInterval ());
256254 throw timeoutException (timeoutMessage , lastException );
257255 }
258256
@@ -280,6 +278,6 @@ protected Throwable propagateIfNotIgnored(Throwable e) {
280278 }
281279 }
282280 Throwables .throwIfUnchecked (e );
283- throw new RuntimeException (e );
281+ throw new WebDriverException (e );
284282 }
285283}
0 commit comments