@@ -311,7 +311,7 @@ Func DemoTimeouts()
311
311
_WD_Timeouts($sSession )
312
312
313
313
; This should timeout
314
- _Demo_NavigateCheckBanner($sSession , " https://yahoo.com" , ' //body[contains(@class, "blur-preview-tpl")]' )
314
+ _Demo_NavigateCheckBanner($sSession , " https://yahoo.com" , ' //body[contains(@class, "blur-preview-tpl")]' )
315
315
If @error Then Return SetError (@error , @extended )
316
316
317
317
; Restore initial settings
@@ -325,7 +325,7 @@ Func DemoNavigation()
325
325
ConsoleWrite (" wd_demo.au3: (" & @ScriptLineNumber & " ) : URL=" & _WD_Action($sSession , ' url' ) & @CRLF )
326
326
327
327
_WD_NewTab($sSession )
328
- _Demo_NavigateCheckBanner($sSession , " https://yahoo.com" , ' //body[contains(@class, "blur-preview-tpl")]' )
328
+ _Demo_NavigateCheckBanner($sSession , " https://yahoo.com" , ' //body[contains(@class, "blur-preview-tpl")]' )
329
329
If @error Then Return SetError (@error , @extended )
330
330
ConsoleWrite (" wd_demo.au3: (" & @ScriptLineNumber & " ) : URL=" & _WD_Action($sSession , ' url' ) & @CRLF )
331
331
@@ -402,7 +402,7 @@ Func DemoElements()
402
402
FileWrite ($hFileOpen , $bDecode )
403
403
FileClose ($hFileOpen )
404
404
405
- _Demo_NavigateCheckBanner($sSession , " hhttps ://demo.guru99.com/test/simple_context_menu.html" , ' //div[@id="gdpr-consent-tool-wrapper" and @aria-hidden="true"]' )
405
+ _Demo_NavigateCheckBanner($sSession , " https ://demo.guru99.com/test/simple_context_menu.html" , ' //div[@id="gdpr-consent-tool-wrapper" and @aria-hidden="true"]' )
406
406
If @error Then Return SetError (@error , @extended )
407
407
408
408
Sleep (2000 )
@@ -430,10 +430,20 @@ EndFunc ;==>DemoElements
430
430
Func DemoScript()
431
431
Local $sValue
432
432
433
+ ; JavaScript example with arguments
433
434
$sValue = _WD_ExecuteScript($sSession , " return arguments[0].second;" , ' {"first": "1st", "second": "2nd", "third": "3rd"}' , Default , $_WD_JSON_Value )
434
435
ConsoleWrite (" wd_demo.au3: (" & @ScriptLineNumber & " ) : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF )
435
436
436
- $sValue = _WD_ExecuteScript($sSession , " dslfkjsdklfj;" , ' {}' , Default , $_WD_JSON_Value )
437
+ ; JavaScript example that fires error because of unknown function
438
+ $sValue = _WD_ExecuteScript($sSession , " dslfkjsdklfj;" , Default , Default , $_WD_JSON_Value )
439
+ ConsoleWrite (" wd_demo.au3: (" & @ScriptLineNumber & " ) : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF )
440
+
441
+ ; JavaScript example that writes to BrowserConsole
442
+ $sValue = _WD_ExecuteScript($sSession , " console.log('Hello world! (from DemoScript: Line #" & @ScriptLineNumber & " )');" , Default , Default , $_WD_JSON_Value )
443
+ ConsoleWrite (" wd_demo.au3: (" & @ScriptLineNumber & " ) : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF )
444
+
445
+ ; JavaScript example with SyntaxError: string literal contains an unescaped line break
446
+ $sValue = _WD_ExecuteScript($sSession , " console.log('Hello world" , Default , Default , $_WD_JSON_Value )
437
447
ConsoleWrite (" wd_demo.au3: (" & @ScriptLineNumber & " ) : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF )
438
448
439
449
; 2022-03-23 This website no longer exists
@@ -524,7 +534,7 @@ EndFunc ;==>DemoAlerts
524
534
Func DemoFrames()
525
535
Local $sElement , $bIsWindowTop
526
536
527
- _Demo_NavigateCheckBanner($sSession , " https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe" , ' //*[@id="snigel-cmp-framework" and @class="snigel-cmp-framework"]' )
537
+ _Demo_NavigateCheckBanner($sSession , " https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe" , ' //*[@id="snigel-cmp-framework" and @class="snigel-cmp-framework"]' )
528
538
If @error Then Return SetError (@error , @extended )
529
539
530
540
Local $iFrameCount = _WD_GetFrameCount($sSession )
@@ -637,7 +647,7 @@ Func DemoWindows()
637
647
638
648
_WD_NewTab($sSession )
639
649
$sHnd2 = ' {"handle":"' & _WD_Window($sSession , " window" ) & ' "}'
640
- _Demo_NavigateCheckBanner($sSession , " https://yahoo.com" , ' //body[contains(@class, "blur-preview-tpl")]' )
650
+ _Demo_NavigateCheckBanner($sSession , " https://yahoo.com" , ' //body[contains(@class, "blur-preview-tpl")]' )
641
651
If @error Then Return SetError (@error , @extended )
642
652
643
653
; Get window coordinates
0 commit comments