28
28
import static org .openqa .selenium .testing .drivers .Browser .SAFARI ;
29
29
30
30
import java .time .Duration ;
31
- import java .util .Arrays ;
32
31
import java .util .Iterator ;
33
32
import java .util .List ;
34
33
import org .junit .jupiter .api .BeforeEach ;
@@ -45,7 +44,7 @@ class ExecutingAsyncJavascriptTest extends JupiterTestBase {
45
44
public void setUp () {
46
45
assumeTrue (driver instanceof JavascriptExecutor );
47
46
executor = (JavascriptExecutor ) driver ;
48
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
47
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
49
48
}
50
49
51
50
@ Test
@@ -56,7 +55,7 @@ public void setUp() {
56
55
public void shouldSetAndGetScriptTimeout () {
57
56
Duration timeout = driver .manage ().timeouts ().getScriptTimeout ();
58
57
assertThat (timeout ).hasMillis (30000 );
59
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (3000 ));
58
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (3000 ));
60
59
Duration timeout2 = driver .manage ().timeouts ().getScriptTimeout ();
61
60
assertThat (timeout2 ).hasMillis (3000 );
62
61
}
@@ -185,7 +184,7 @@ public void shouldNotTimeoutIfScriptCallsbackInsideAZeroTimeout() {
185
184
@ Test
186
185
@ NotYetImplemented (SAFARI )
187
186
public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout () {
188
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (500 ));
187
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (500 ));
189
188
driver .get (pages .ajaxyPage );
190
189
assertThatExceptionOfType (ScriptTimeoutException .class )
191
190
.isThrownBy (
@@ -199,7 +198,7 @@ public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout() {
199
198
@ Ignore (IE )
200
199
public void shouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError () {
201
200
driver .get (pages .ajaxyPage );
202
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (100 ));
201
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (100 ));
203
202
assertThatExceptionOfType (WebDriverException .class )
204
203
.isThrownBy (
205
204
() -> executor .executeAsyncScript ("window.location = '" + pages .dynamicPage + "';" ));
@@ -244,7 +243,7 @@ public void shouldCatchErrorsWithMessageAndStacktraceWhenExecutingInitialScript(
244
243
t -> {
245
244
Throwable rootCause = getRootCause (t );
246
245
assertThat (rootCause ).hasMessageContaining ("errormessage" );
247
- assertThat (Arrays . asList (rootCause .getStackTrace ()))
246
+ assertThat (List . of (rootCause .getStackTrace ()))
248
247
.extracting (StackTraceElement ::getMethodName )
249
248
.contains ("functionB" );
250
249
});
@@ -266,7 +265,7 @@ void shouldBeAbleToExecuteAsynchronousScripts() {
266
265
"There should only be 1 DIV at this point, which is used for the butter message" )
267
266
.isEqualTo (1 );
268
267
269
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofSeconds (15 ));
268
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofSeconds (15 ));
270
269
String text =
271
270
(String )
272
271
executor .executeAsyncScript (
@@ -317,7 +316,7 @@ void shouldBeAbleToMakeXMLHttpRequestsAndWaitForTheResponse() {
317
316
+ "xhr.send('');" ; // empty string to stop firefox 3 from choking
318
317
319
318
driver .get (pages .ajaxyPage );
320
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofSeconds (3 ));
319
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofSeconds (3 ));
321
320
String response = (String ) executor .executeAsyncScript (script , pages .sleepingPage + "?time=2" );
322
321
assertThat (response .trim ())
323
322
.isEqualTo ("<html><head><title>Done</title></head><body>Slept for 2s</body></html>" );
@@ -331,7 +330,7 @@ void shouldBeAbleToMakeXMLHttpRequestsAndWaitForTheResponse() {
331
330
@ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
332
331
public void throwsIfScriptTriggersAlert () {
333
332
driver .get (pages .simpleTestPage );
334
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
333
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
335
334
assertThatExceptionOfType (UnhandledAlertException .class )
336
335
.isThrownBy (
337
336
() ->
@@ -350,7 +349,7 @@ public void throwsIfScriptTriggersAlert() {
350
349
@ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
351
350
public void throwsIfAlertHappensDuringScript () {
352
351
driver .get (pages .slowLoadingAlertPage );
353
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
352
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
354
353
assertThatExceptionOfType (UnhandledAlertException .class )
355
354
.isThrownBy (() -> executor .executeAsyncScript ("setTimeout(arguments[0], 1000);" ));
356
355
// Shouldn't throw
@@ -365,7 +364,7 @@ public void throwsIfAlertHappensDuringScript() {
365
364
@ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
366
365
public void throwsIfScriptTriggersAlertWhichTimesOut () {
367
366
driver .get (pages .simpleTestPage );
368
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
367
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
369
368
assertThatExceptionOfType (UnhandledAlertException .class )
370
369
.isThrownBy (
371
370
() ->
@@ -383,7 +382,7 @@ public void throwsIfScriptTriggersAlertWhichTimesOut() {
383
382
@ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
384
383
public void throwsIfAlertHappensDuringScriptWhichTimesOut () {
385
384
driver .get (pages .slowLoadingAlertPage );
386
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
385
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
387
386
assertThatExceptionOfType (UnhandledAlertException .class )
388
387
.isThrownBy (() -> executor .executeAsyncScript ("" ));
389
388
// Shouldn't throw
@@ -397,7 +396,7 @@ public void throwsIfAlertHappensDuringScriptWhichTimesOut() {
397
396
@ Ignore (FIREFOX )
398
397
@ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
399
398
public void includesAlertTextInUnhandledAlertException () {
400
- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
399
+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
401
400
String alertText = "Look! An alert!" ;
402
401
assertThatExceptionOfType (UnhandledAlertException .class )
403
402
.isThrownBy (
0 commit comments