Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 2 additions & 53 deletions java/src/org/openqa/selenium/WebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -326,38 +325,6 @@ default Duration getImplicitWaitTimeout() {
throw new UnsupportedCommandException();
}

/**
* @deprecated Use {@link #scriptTimeout(Duration)}
* <p>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 <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
*/
@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 <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
*/
@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
Expand All @@ -369,9 +336,7 @@ default Timeouts setScriptTimeout(Duration duration) {
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
*/
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
Expand All @@ -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 <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
* @deprecated Use {@link #pageLoadTimeout(Duration)}
* <p>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
Expand All @@ -410,9 +361,7 @@ default Duration getScriptTimeout() {
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
*/
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
Expand Down
19 changes: 0 additions & 19 deletions java/src/org/openqa/selenium/remote/DriverCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
}
Expand Down
19 changes: 0 additions & 19 deletions java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down
26 changes: 24 additions & 2 deletions java/src/org/openqa/selenium/support/events/WebDriverListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,29 +58,14 @@ private void verifyFunction(Consumer<WebDriver.Timeouts> f) {
verifyNoMoreInteractions(fixture.original);
}

@Test
void implicitlyWaitLegacy() {
verifyFunction($ -> $.implicitlyWait(Duration.ofSeconds(10)));
}

@Test
void implicitlyWait() {
verifyFunction($ -> $.implicitlyWait(Duration.ofSeconds(10)));
}

@Test
void setScriptTimeoutLegacy() {
verifyFunction($ -> $.setScriptTimeout(10, TimeUnit.SECONDS));
}

@Test
void setScriptTimeout() {
verifyFunction($ -> $.setScriptTimeout(Duration.ofSeconds(10)));
}

@Test
void pageLoadTimeoutLegacy() {
verifyFunction($ -> $.pageLoadTimeout(10, TimeUnit.SECONDS));
verifyFunction($ -> $.scriptTimeout(Duration.ofSeconds(10)));
}

@Test
Expand Down
Loading