diff --git a/java/src/org/openqa/selenium/WebDriver.java b/java/src/org/openqa/selenium/WebDriver.java index d126925e8e246..0dbee90ba4cdb 100644 --- a/java/src/org/openqa/selenium/WebDriver.java +++ b/java/src/org/openqa/selenium/WebDriver.java @@ -21,7 +21,6 @@ import java.time.Duration; import java.util.List; import java.util.Set; -import java.util.concurrent.TimeUnit; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import org.openqa.selenium.logging.LoggingPreferences; @@ -326,38 +325,6 @@ default Duration getImplicitWaitTimeout() { throw new UnsupportedCommandException(); } - /** - * @deprecated Use {@link #scriptTimeout(Duration)} - *
Sets the amount of time to wait for an asynchronous script to finish execution before - * throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an - * error code with invalid argument will be returned. - * @param time The timeout value. - * @param unit The unit of time. - * @return A self reference. - * @see JavascriptExecutor#executeAsyncScript(String, Object...) - * @see W3C WebDriver - * @see W3C WebDriver - */ - @Deprecated - Timeouts setScriptTimeout(long time, TimeUnit unit); - - /** - * Sets the amount of time to wait for an asynchronous script to finish execution before - * throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an error - * code with invalid argument will be returned. - * - * @param duration The timeout value. - * @deprecated Use {@link #scriptTimeout(Duration)} - * @return A self reference. - * @see JavascriptExecutor#executeAsyncScript(String, Object...) - * @see W3C WebDriver - * @see W3C WebDriver - */ - @Deprecated - default Timeouts setScriptTimeout(Duration duration) { - return setScriptTimeout(duration.toMillis(), TimeUnit.MILLISECONDS); - } - /** * Sets the amount of time to wait for an asynchronous script to finish execution before * 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) { * @see W3C WebDriver * @see W3C WebDriver */ - default Timeouts scriptTimeout(Duration duration) { - return setScriptTimeout(duration); - } + Timeouts scriptTimeout(Duration duration); /** * Gets the amount of time to wait for an asynchronous script to finish execution before @@ -386,20 +351,6 @@ default Duration getScriptTimeout() { throw new UnsupportedCommandException(); } - /** - * @param time The timeout value. - * @param unit The unit of time. - * @return A Timeouts interface. - * @see W3C WebDriver - * @see W3C WebDriver - * @deprecated Use {@link #pageLoadTimeout(Duration)} - *
Sets the amount of time to wait for a page load to complete before throwing an error.
- * If the timeout is negative, not null, or greater than 2e16 - 1, an error code with
- * invalid argument will be returned.
- */
- @Deprecated
- Timeouts pageLoadTimeout(long time, TimeUnit unit);
-
/**
* Sets the amount of time to wait for a page load to complete before throwing an error. If the
* timeout is negative, not null, or greater than 2e16 - 1, an error code with invalid argument
@@ -410,9 +361,7 @@ default Duration getScriptTimeout() {
* @see W3C WebDriver
* @see W3C WebDriver
*/
- default Timeouts pageLoadTimeout(Duration duration) {
- return pageLoadTimeout(duration.toMillis(), TimeUnit.MILLISECONDS);
- }
+ Timeouts pageLoadTimeout(Duration duration);
/**
* Gets the amount of time to wait for a page load to complete before throwing an error. If the
diff --git a/java/src/org/openqa/selenium/remote/DriverCommand.java b/java/src/org/openqa/selenium/remote/DriverCommand.java
index a027828f1574e..a498eb297267e 100644
--- a/java/src/org/openqa/selenium/remote/DriverCommand.java
+++ b/java/src/org/openqa/selenium/remote/DriverCommand.java
@@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.Dimension;
@@ -341,32 +340,14 @@ static CommandPayload PRINT_PAGE(PrintOptions options) {
return new CommandPayload(PRINT_PAGE, options.toMap());
}
- @Deprecated
- static CommandPayload SET_IMPLICIT_WAIT_TIMEOUT(long time, TimeUnit unit) {
- return new CommandPayload(
- SET_TIMEOUT, Map.of("implicit", TimeUnit.MILLISECONDS.convert(time, unit)));
- }
-
static CommandPayload SET_IMPLICIT_WAIT_TIMEOUT(Duration duration) {
return new CommandPayload(SET_TIMEOUT, Map.of("implicit", duration.toMillis()));
}
- @Deprecated
- static CommandPayload SET_SCRIPT_TIMEOUT(long time, TimeUnit unit) {
- return new CommandPayload(
- SET_TIMEOUT, Map.of("script", TimeUnit.MILLISECONDS.convert(time, unit)));
- }
-
static CommandPayload SET_SCRIPT_TIMEOUT(Duration duration) {
return new CommandPayload(SET_TIMEOUT, Map.of("script", duration.toMillis()));
}
- @Deprecated
- static CommandPayload SET_PAGE_LOAD_TIMEOUT(long time, TimeUnit unit) {
- return new CommandPayload(
- SET_TIMEOUT, Map.of("pageLoad", TimeUnit.MILLISECONDS.convert(time, unit)));
- }
-
static CommandPayload SET_PAGE_LOAD_TIMEOUT(Duration duration) {
return new CommandPayload(SET_TIMEOUT, Map.of("pageLoad", duration.toMillis()));
}
diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java
index 0a392dc1aa670..6c176e34dad07 100644
--- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java
+++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java
@@ -37,7 +37,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -969,18 +968,6 @@ public Duration getImplicitWaitTimeout() {
return Duration.ofMillis(timeout);
}
- @Deprecated
- @Override
- public Timeouts setScriptTimeout(long time, TimeUnit unit) {
- return setScriptTimeout(Duration.ofMillis(unit.toMillis(time)));
- }
-
- @Deprecated
- @Override
- public Timeouts setScriptTimeout(Duration duration) {
- return scriptTimeout(duration);
- }
-
@Override
public Timeouts scriptTimeout(Duration duration) {
execute(DriverCommand.SET_SCRIPT_TIMEOUT(duration));
@@ -995,12 +982,6 @@ public Duration getScriptTimeout() {
return Duration.ofMillis(timeout);
}
- @Deprecated
- @Override
- public Timeouts pageLoadTimeout(long time, TimeUnit unit) {
- return pageLoadTimeout(Duration.ofMillis(unit.toMillis(time)));
- }
-
@Override
public Timeouts pageLoadTimeout(Duration duration) {
execute(DriverCommand.SET_PAGE_LOAD_TIMEOUT(duration));
diff --git a/java/src/org/openqa/selenium/support/events/WebDriverListener.java b/java/src/org/openqa/selenium/support/events/WebDriverListener.java
index 731e610d03028..32ee9f0b93faa 100644
--- a/java/src/org/openqa/selenium/support/events/WebDriverListener.java
+++ b/java/src/org/openqa/selenium/support/events/WebDriverListener.java
@@ -909,22 +909,44 @@ default void afterImplicitlyWait(WebDriver.Timeouts timeouts, Duration duration)
/**
* This action will be performed each time before {@link
- * WebDriver.Timeouts#setScriptTimeout(Duration)} is called.
+ * WebDriver.Timeouts#scriptTimeout(Duration)} is called.
*
* @param timeouts The timeouts object that will be called
* @param duration The duration that will be passed to the method
+ * @deprecated Use {@link #beforeScriptTimeout(WebDriver.Timeouts, Duration)} instead.
*/
+ @Deprecated
default void beforeSetScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
+ /**
+ * This action will be performed each time before {@link
+ * WebDriver.Timeouts#scriptTimeout(Duration)} is called.
+ *
+ * @param timeouts The timeouts object that will be called
+ * @param duration The duration that will be passed to the method
+ */
+ default void beforeScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
+
/**
* This action will be performed each time after {@link
- * WebDriver.Timeouts#setScriptTimeout(Duration)} is called.
+ * WebDriver.Timeouts#scriptTimeout(Duration)} is called.
*
* @param timeouts The timeouts object that will be called
* @param duration The duration that will be passed to the method
+ * @deprecated Use {@link #afterScriptTimeout(WebDriver.Timeouts, Duration)} instead.
*/
+ @Deprecated
default void afterSetScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
+ /**
+ * This action will be performed each time after {@link
+ * WebDriver.Timeouts#scriptTimeout(Duration)} is called.
+ *
+ * @param timeouts The timeouts object that will be called
+ * @param duration The duration that will be passed to the method
+ */
+ default void afterScriptTimeout(WebDriver.Timeouts timeouts, Duration duration) {}
+
/**
* This action will be performed each time before {@link
* WebDriver.Timeouts#pageLoadTimeout(Duration)} is called.
diff --git a/java/test/org/openqa/selenium/support/decorators/DecoratedTimeoutsTest.java b/java/test/org/openqa/selenium/support/decorators/DecoratedTimeoutsTest.java
index 15102c4ff2396..f1750514f5b4e 100644
--- a/java/test/org/openqa/selenium/support/decorators/DecoratedTimeoutsTest.java
+++ b/java/test/org/openqa/selenium/support/decorators/DecoratedTimeoutsTest.java
@@ -24,7 +24,6 @@
import static org.mockito.Mockito.when;
import java.time.Duration;
-import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -59,29 +58,14 @@ private void verifyFunction(Consumer