Skip to content

Commit 638621f

Browse files
authored
[java] Removing deprecated setScriptTimeout and pageLoadTimeout. (#15764)
1 parent 57f0701 commit 638621f

File tree

5 files changed

+27
-110
lines changed

5 files changed

+27
-110
lines changed

java/src/org/openqa/selenium/WebDriver.java

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.time.Duration;
2222
import java.util.List;
2323
import java.util.Set;
24-
import java.util.concurrent.TimeUnit;
2524
import org.jspecify.annotations.NullMarked;
2625
import org.jspecify.annotations.Nullable;
2726
import org.openqa.selenium.logging.LoggingPreferences;
@@ -326,38 +325,6 @@ default Duration getImplicitWaitTimeout() {
326325
throw new UnsupportedCommandException();
327326
}
328327

329-
/**
330-
* @deprecated Use {@link #scriptTimeout(Duration)}
331-
* <p>Sets the amount of time to wait for an asynchronous script to finish execution before
332-
* throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an
333-
* error code with invalid argument will be returned.
334-
* @param time The timeout value.
335-
* @param unit The unit of time.
336-
* @return A self reference.
337-
* @see JavascriptExecutor#executeAsyncScript(String, Object...)
338-
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
339-
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
340-
*/
341-
@Deprecated
342-
Timeouts setScriptTimeout(long time, TimeUnit unit);
343-
344-
/**
345-
* Sets the amount of time to wait for an asynchronous script to finish execution before
346-
* throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an error
347-
* code with invalid argument will be returned.
348-
*
349-
* @param duration The timeout value.
350-
* @deprecated Use {@link #scriptTimeout(Duration)}
351-
* @return A self reference.
352-
* @see JavascriptExecutor#executeAsyncScript(String, Object...)
353-
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
354-
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
355-
*/
356-
@Deprecated
357-
default Timeouts setScriptTimeout(Duration duration) {
358-
return setScriptTimeout(duration.toMillis(), TimeUnit.MILLISECONDS);
359-
}
360-
361328
/**
362329
* Sets the amount of time to wait for an asynchronous script to finish execution before
363330
* throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an error
@@ -369,9 +336,7 @@ default Timeouts setScriptTimeout(Duration duration) {
369336
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
370337
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
371338
*/
372-
default Timeouts scriptTimeout(Duration duration) {
373-
return setScriptTimeout(duration);
374-
}
339+
Timeouts scriptTimeout(Duration duration);
375340

376341
/**
377342
* Gets the amount of time to wait for an asynchronous script to finish execution before
@@ -386,20 +351,6 @@ default Duration getScriptTimeout() {
386351
throw new UnsupportedCommandException();
387352
}
388353

389-
/**
390-
* @param time The timeout value.
391-
* @param unit The unit of time.
392-
* @return A Timeouts interface.
393-
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
394-
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
395-
* @deprecated Use {@link #pageLoadTimeout(Duration)}
396-
* <p>Sets the amount of time to wait for a page load to complete before throwing an error.
397-
* If the timeout is negative, not null, or greater than 2e16 - 1, an error code with
398-
* invalid argument will be returned.
399-
*/
400-
@Deprecated
401-
Timeouts pageLoadTimeout(long time, TimeUnit unit);
402-
403354
/**
404355
* Sets the amount of time to wait for a page load to complete before throwing an error. If the
405356
* timeout is negative, not null, or greater than 2e16 - 1, an error code with invalid argument
@@ -410,9 +361,7 @@ default Duration getScriptTimeout() {
410361
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
411362
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
412363
*/
413-
default Timeouts pageLoadTimeout(Duration duration) {
414-
return pageLoadTimeout(duration.toMillis(), TimeUnit.MILLISECONDS);
415-
}
364+
Timeouts pageLoadTimeout(Duration duration);
416365

417366
/**
418367
* Gets the amount of time to wait for a page load to complete before throwing an error. If the

java/src/org/openqa/selenium/remote/DriverCommand.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.Collection;
2525
import java.util.List;
2626
import java.util.Map;
27-
import java.util.concurrent.TimeUnit;
2827
import org.openqa.selenium.Capabilities;
2928
import org.openqa.selenium.Cookie;
3029
import org.openqa.selenium.Dimension;
@@ -341,32 +340,14 @@ static CommandPayload PRINT_PAGE(PrintOptions options) {
341340
return new CommandPayload(PRINT_PAGE, options.toMap());
342341
}
343342

344-
@Deprecated
345-
static CommandPayload SET_IMPLICIT_WAIT_TIMEOUT(long time, TimeUnit unit) {
346-
return new CommandPayload(
347-
SET_TIMEOUT, Map.of("implicit", TimeUnit.MILLISECONDS.convert(time, unit)));
348-
}
349-
350343
static CommandPayload SET_IMPLICIT_WAIT_TIMEOUT(Duration duration) {
351344
return new CommandPayload(SET_TIMEOUT, Map.of("implicit", duration.toMillis()));
352345
}
353346

354-
@Deprecated
355-
static CommandPayload SET_SCRIPT_TIMEOUT(long time, TimeUnit unit) {
356-
return new CommandPayload(
357-
SET_TIMEOUT, Map.of("script", TimeUnit.MILLISECONDS.convert(time, unit)));
358-
}
359-
360347
static CommandPayload SET_SCRIPT_TIMEOUT(Duration duration) {
361348
return new CommandPayload(SET_TIMEOUT, Map.of("script", duration.toMillis()));
362349
}
363350

364-
@Deprecated
365-
static CommandPayload SET_PAGE_LOAD_TIMEOUT(long time, TimeUnit unit) {
366-
return new CommandPayload(
367-
SET_TIMEOUT, Map.of("pageLoad", TimeUnit.MILLISECONDS.convert(time, unit)));
368-
}
369-
370351
static CommandPayload SET_PAGE_LOAD_TIMEOUT(Duration duration) {
371352
return new CommandPayload(SET_TIMEOUT, Map.of("pageLoad", duration.toMillis()));
372353
}

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.List;
3838
import java.util.Map;
3939
import java.util.Set;
40-
import java.util.concurrent.TimeUnit;
4140
import java.util.function.BiFunction;
4241
import java.util.logging.Level;
4342
import java.util.logging.Logger;
@@ -969,18 +968,6 @@ public Duration getImplicitWaitTimeout() {
969968
return Duration.ofMillis(timeout);
970969
}
971970

972-
@Deprecated
973-
@Override
974-
public Timeouts setScriptTimeout(long time, TimeUnit unit) {
975-
return setScriptTimeout(Duration.ofMillis(unit.toMillis(time)));
976-
}
977-
978-
@Deprecated
979-
@Override
980-
public Timeouts setScriptTimeout(Duration duration) {
981-
return scriptTimeout(duration);
982-
}
983-
984971
@Override
985972
public Timeouts scriptTimeout(Duration duration) {
986973
execute(DriverCommand.SET_SCRIPT_TIMEOUT(duration));
@@ -995,12 +982,6 @@ public Duration getScriptTimeout() {
995982
return Duration.ofMillis(timeout);
996983
}
997984

998-
@Deprecated
999-
@Override
1000-
public Timeouts pageLoadTimeout(long time, TimeUnit unit) {
1001-
return pageLoadTimeout(Duration.ofMillis(unit.toMillis(time)));
1002-
}
1003-
1004985
@Override
1005986
public Timeouts pageLoadTimeout(Duration duration) {
1006987
execute(DriverCommand.SET_PAGE_LOAD_TIMEOUT(duration));

java/src/org/openqa/selenium/support/events/WebDriverListener.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,22 +909,44 @@ default void afterImplicitlyWait(WebDriver.Timeouts timeouts, Duration duration)
909909

910910
/**
911911
* This action will be performed each time before {@link
912-
* WebDriver.Timeouts#setScriptTimeout(Duration)} is called.
912+
* WebDriver.Timeouts#scriptTimeout(Duration)} is called.
913913
*
914914
* @param timeouts The timeouts object that will be called
915915
* @param duration The duration that will be passed to the method
916+
* @deprecated Use {@link #beforeScriptTimeout(WebDriver.Timeouts, Duration)} instead.
916917
*/
918+
@Deprecated
917919
default void beforeSetScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
918920

921+
/**
922+
* This action will be performed each time before {@link
923+
* WebDriver.Timeouts#scriptTimeout(Duration)} is called.
924+
*
925+
* @param timeouts The timeouts object that will be called
926+
* @param duration The duration that will be passed to the method
927+
*/
928+
default void beforeScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
929+
919930
/**
920931
* This action will be performed each time after {@link
921-
* WebDriver.Timeouts#setScriptTimeout(Duration)} is called.
932+
* WebDriver.Timeouts#scriptTimeout(Duration)} is called.
922933
*
923934
* @param timeouts The timeouts object that will be called
924935
* @param duration The duration that will be passed to the method
936+
* @deprecated Use {@link #afterScriptTimeout(WebDriver.Timeouts, Duration)} instead.
925937
*/
938+
@Deprecated
926939
default void afterSetScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
927940

941+
/**
942+
* This action will be performed each time after {@link
943+
* WebDriver.Timeouts#scriptTimeout(Duration)} is called.
944+
*
945+
* @param timeouts The timeouts object that will be called
946+
* @param duration The duration that will be passed to the method
947+
*/
948+
default void afterScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
949+
928950
/**
929951
* This action will be performed each time before {@link
930952
* WebDriver.Timeouts#pageLoadTimeout(Duration)} is called.

java/test/org/openqa/selenium/support/decorators/DecoratedTimeoutsTest.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import static org.mockito.Mockito.when;
2525

2626
import java.time.Duration;
27-
import java.util.concurrent.TimeUnit;
2827
import java.util.function.Consumer;
2928
import org.junit.jupiter.api.Tag;
3029
import org.junit.jupiter.api.Test;
@@ -59,29 +58,14 @@ private void verifyFunction(Consumer<WebDriver.Timeouts> f) {
5958
verifyNoMoreInteractions(fixture.original);
6059
}
6160

62-
@Test
63-
void implicitlyWaitLegacy() {
64-
verifyFunction($ -> $.implicitlyWait(Duration.ofSeconds(10)));
65-
}
66-
6761
@Test
6862
void implicitlyWait() {
6963
verifyFunction($ -> $.implicitlyWait(Duration.ofSeconds(10)));
7064
}
7165

72-
@Test
73-
void setScriptTimeoutLegacy() {
74-
verifyFunction($ -> $.setScriptTimeout(10, TimeUnit.SECONDS));
75-
}
76-
7766
@Test
7867
void setScriptTimeout() {
79-
verifyFunction($ -> $.setScriptTimeout(Duration.ofSeconds(10)));
80-
}
81-
82-
@Test
83-
void pageLoadTimeoutLegacy() {
84-
verifyFunction($ -> $.pageLoadTimeout(10, TimeUnit.SECONDS));
68+
verifyFunction($ -> $.scriptTimeout(Duration.ofSeconds(10)));
8569
}
8670

8771
@Test

0 commit comments

Comments
 (0)