2828import static org .openqa .selenium .testing .drivers .Browser .SAFARI ;
2929
3030import java .time .Duration ;
31- import java .util .Arrays ;
3231import java .util .Iterator ;
3332import java .util .List ;
3433import org .junit .jupiter .api .BeforeEach ;
@@ -45,7 +44,7 @@ class ExecutingAsyncJavascriptTest extends JupiterTestBase {
4544 public void setUp () {
4645 assumeTrue (driver instanceof JavascriptExecutor );
4746 executor = (JavascriptExecutor ) driver ;
48- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
47+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
4948 }
5049
5150 @ Test
@@ -56,7 +55,7 @@ public void setUp() {
5655 public void shouldSetAndGetScriptTimeout () {
5756 Duration timeout = driver .manage ().timeouts ().getScriptTimeout ();
5857 assertThat (timeout ).hasMillis (30000 );
59- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (3000 ));
58+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (3000 ));
6059 Duration timeout2 = driver .manage ().timeouts ().getScriptTimeout ();
6160 assertThat (timeout2 ).hasMillis (3000 );
6261 }
@@ -185,7 +184,7 @@ public void shouldNotTimeoutIfScriptCallsbackInsideAZeroTimeout() {
185184 @ Test
186185 @ NotYetImplemented (SAFARI )
187186 public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout () {
188- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (500 ));
187+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (500 ));
189188 driver .get (pages .ajaxyPage );
190189 assertThatExceptionOfType (ScriptTimeoutException .class )
191190 .isThrownBy (
@@ -199,7 +198,7 @@ public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout() {
199198 @ Ignore (IE )
200199 public void shouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError () {
201200 driver .get (pages .ajaxyPage );
202- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (100 ));
201+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (100 ));
203202 assertThatExceptionOfType (WebDriverException .class )
204203 .isThrownBy (
205204 () -> executor .executeAsyncScript ("window.location = '" + pages .dynamicPage + "';" ));
@@ -244,7 +243,7 @@ public void shouldCatchErrorsWithMessageAndStacktraceWhenExecutingInitialScript(
244243 t -> {
245244 Throwable rootCause = getRootCause (t );
246245 assertThat (rootCause ).hasMessageContaining ("errormessage" );
247- assertThat (Arrays . asList (rootCause .getStackTrace ()))
246+ assertThat (List . of (rootCause .getStackTrace ()))
248247 .extracting (StackTraceElement ::getMethodName )
249248 .contains ("functionB" );
250249 });
@@ -266,7 +265,7 @@ void shouldBeAbleToExecuteAsynchronousScripts() {
266265 "There should only be 1 DIV at this point, which is used for the butter message" )
267266 .isEqualTo (1 );
268267
269- driver .manage ().timeouts ().setScriptTimeout (Duration .ofSeconds (15 ));
268+ driver .manage ().timeouts ().scriptTimeout (Duration .ofSeconds (15 ));
270269 String text =
271270 (String )
272271 executor .executeAsyncScript (
@@ -317,7 +316,7 @@ void shouldBeAbleToMakeXMLHttpRequestsAndWaitForTheResponse() {
317316 + "xhr.send('');" ; // empty string to stop firefox 3 from choking
318317
319318 driver .get (pages .ajaxyPage );
320- driver .manage ().timeouts ().setScriptTimeout (Duration .ofSeconds (3 ));
319+ driver .manage ().timeouts ().scriptTimeout (Duration .ofSeconds (3 ));
321320 String response = (String ) executor .executeAsyncScript (script , pages .sleepingPage + "?time=2" );
322321 assertThat (response .trim ())
323322 .isEqualTo ("<html><head><title>Done</title></head><body>Slept for 2s</body></html>" );
@@ -331,7 +330,7 @@ void shouldBeAbleToMakeXMLHttpRequestsAndWaitForTheResponse() {
331330 @ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
332331 public void throwsIfScriptTriggersAlert () {
333332 driver .get (pages .simpleTestPage );
334- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
333+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
335334 assertThatExceptionOfType (UnhandledAlertException .class )
336335 .isThrownBy (
337336 () ->
@@ -350,7 +349,7 @@ public void throwsIfScriptTriggersAlert() {
350349 @ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
351350 public void throwsIfAlertHappensDuringScript () {
352351 driver .get (pages .slowLoadingAlertPage );
353- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
352+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
354353 assertThatExceptionOfType (UnhandledAlertException .class )
355354 .isThrownBy (() -> executor .executeAsyncScript ("setTimeout(arguments[0], 1000);" ));
356355 // Shouldn't throw
@@ -365,7 +364,7 @@ public void throwsIfAlertHappensDuringScript() {
365364 @ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
366365 public void throwsIfScriptTriggersAlertWhichTimesOut () {
367366 driver .get (pages .simpleTestPage );
368- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
367+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
369368 assertThatExceptionOfType (UnhandledAlertException .class )
370369 .isThrownBy (
371370 () ->
@@ -383,7 +382,7 @@ public void throwsIfScriptTriggersAlertWhichTimesOut() {
383382 @ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
384383 public void throwsIfAlertHappensDuringScriptWhichTimesOut () {
385384 driver .get (pages .slowLoadingAlertPage );
386- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
385+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
387386 assertThatExceptionOfType (UnhandledAlertException .class )
388387 .isThrownBy (() -> executor .executeAsyncScript ("" ));
389388 // Shouldn't throw
@@ -397,7 +396,7 @@ public void throwsIfAlertHappensDuringScriptWhichTimesOut() {
397396 @ Ignore (FIREFOX )
398397 @ Ignore (value = SAFARI , reason = "Does not support alerts yet" )
399398 public void includesAlertTextInUnhandledAlertException () {
400- driver .manage ().timeouts ().setScriptTimeout (Duration .ofMillis (5000 ));
399+ driver .manage ().timeouts ().scriptTimeout (Duration .ofMillis (5000 ));
401400 String alertText = "Look! An alert!" ;
402401 assertThatExceptionOfType (UnhandledAlertException .class )
403402 .isThrownBy (
0 commit comments