From 343aa78b5872f814645e771ac88ee47307eeea9c Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Tue, 19 Dec 2023 04:29:43 -0500 Subject: [PATCH] Add Duration overload to SlowLoadableComponent constructor (#13309) * Add Duration overload to SlowLoadableComponent constructor * Deprecate SlowLoadableComponent(Clock, int) * Formatting files --------- Co-authored-by: Diego Molina Co-authored-by: Diego Molina --- .../support/ui/SlowLoadableComponent.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/java/src/org/openqa/selenium/support/ui/SlowLoadableComponent.java b/java/src/org/openqa/selenium/support/ui/SlowLoadableComponent.java index e58a99462e57c..04af0a3dfd62e 100644 --- a/java/src/org/openqa/selenium/support/ui/SlowLoadableComponent.java +++ b/java/src/org/openqa/selenium/support/ui/SlowLoadableComponent.java @@ -36,11 +36,19 @@ public abstract class SlowLoadableComponent> extends LoadableComponent { private final Clock clock; - private final Duration timeOutInSeconds; + private final Duration timeOut; - public SlowLoadableComponent(java.time.Clock clock, int timeOutInSeconds) { + /** + * @deprecated Use {@link #SlowLoadableComponent(Clock, Duration)} instead. + */ + @Deprecated + public SlowLoadableComponent(Clock clock, int timeOutInSeconds) { + this(clock, Duration.ofSeconds(timeOutInSeconds)); + } + + public SlowLoadableComponent(Clock clock, Duration timeOut) { this.clock = clock; - this.timeOutInSeconds = Duration.ofSeconds(timeOutInSeconds); + this.timeOut = timeOut; } @Override @@ -53,7 +61,7 @@ public T get() { load(); } - Instant end = clock.instant().plus(timeOutInSeconds); + Instant end = clock.instant().plus(timeOut); while (clock.instant().isBefore(end)) { try {