Skip to content

Commit f3e5963

Browse files
committed
adding javadoc to JavascriptExecutor executeAsyncScript about the default timeout. Also some extra information on troubleshooting common issues.
Fixes Issue #5331
1 parent 229567f commit f3e5963

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
/**
2020
* Indicates that a driver can execute JavaScript, providing access to the mechanism to do so.
21+
*
22+
* <p>
23+
* Because of cross domain policies browsers enforce your script execution may fail unexpectedly
24+
* and without adequate error messaging. This is particularly pertinent when creating your own
25+
* XHR request or when trying to access another frame. Most times when troubleshooting failure it's
26+
* best to view the browser's console after executing the WebDriver request.
2127
*/
2228
public interface JavascriptExecutor {
2329
/**
@@ -76,6 +82,13 @@ public interface JavascriptExecutor {
7682
* support nested lists.</li>
7783
* <li>Unless the value is null or there is no return value, in which null is returned</li>
7884
* </ul>
85+
*
86+
* <p>
87+
* The default timeout for a script to be executed is 0ms. In most cases, including the examples
88+
* below, one must set the script timeout
89+
* {@link WebDriver.Timeouts#setScriptTimeout(long, java.util.concurrent.TimeUnit)} beforehand
90+
* to a value sufficiently large enough.
91+
*
7992
*
8093
* <p>
8194
* Example #1: Performing a sleep in the browser under test. <code><pre>
@@ -119,9 +132,11 @@ public interface JavascriptExecutor {
119132
* criteria. The arguments will be made available to the JavaScript via the "arguments"
120133
* variable.
121134
*
135+
*
122136
* @param script The JavaScript to execute.
123137
* @param args The arguments to the script. May be empty.
124138
* @return One of Boolean, Long, String, List, WebElement, or null.
139+
* @see WebDriver.Timeouts#setScriptTimeout(long, java.util.concurrent.TimeUnit)
125140
*/
126141
Object executeAsyncScript(String script, Object... args);
127142
}

0 commit comments

Comments
 (0)