Skip to content

Commit afa9187

Browse files
committed
Make setting the script timeout consistent with setting other timeouts
1 parent 53ad48f commit afa9187

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,32 @@ default Duration getImplicitWaitTimeout() {
384384
* error code with invalid argument will be returned.
385385
*
386386
* @param duration The timeout value.
387+
* @deprecated Use {@link #scriptTimeout(Duration)}
387388
* @return A self reference.
388389
* @see JavascriptExecutor#executeAsyncScript(String, Object...)
389390
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
390391
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
391392
*/
393+
@Deprecated
392394
default Timeouts setScriptTimeout(Duration duration) {
393395
return setScriptTimeout(duration.toMillis(), TimeUnit.MILLISECONDS);
394396
}
395397

398+
/**
399+
* Sets the amount of time to wait for an asynchronous script to finish execution before
400+
* throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an
401+
* error code with invalid argument will be returned.
402+
*
403+
* @param duration The timeout value.
404+
* @return A self reference.
405+
* @see JavascriptExecutor#executeAsyncScript(String, Object...)
406+
* @see <a href="https://www.w3.org/TR/webdriver/#set-timeouts">W3C WebDriver</a>
407+
* @see <a href="https://www.w3.org/TR/webdriver/#dfn-timeouts-configuration">W3C WebDriver</a>
408+
*/
409+
default Timeouts scriptTimeout(Duration duration) {
410+
return setScriptTimeout(duration);
411+
}
412+
396413
/**
397414
* Gets the amount of time to wait for an asynchronous script to finish execution before
398415
* throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,11 @@ public Timeouts setScriptTimeout(long time, TimeUnit unit) {
899899

900900
@Override
901901
public Timeouts setScriptTimeout(Duration duration) {
902+
return scriptTimeout(duration);
903+
}
904+
905+
@Override
906+
public Timeouts scriptTimeout(Duration duration) {
902907
execute(DriverCommand.SET_SCRIPT_TIMEOUT(duration));
903908
return this;
904909
}

0 commit comments

Comments
 (0)