Skip to content

Commit b34c299

Browse files
authored
wd_demo.au3 - DemoScript() examples + descriptions (#299)
1 parent 50e2cc4 commit b34c299

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

wd_demo.au3

+16-6
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ Func DemoTimeouts()
311311
_WD_Timeouts($sSession)
312312

313313
; 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")]')
315315
If @error Then Return SetError(@error, @extended)
316316

317317
; Restore initial settings
@@ -325,7 +325,7 @@ Func DemoNavigation()
325325
ConsoleWrite("wd_demo.au3: (" & @ScriptLineNumber & ") : URL=" & _WD_Action($sSession, 'url') & @CRLF)
326326

327327
_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")]')
329329
If @error Then Return SetError(@error, @extended)
330330
ConsoleWrite("wd_demo.au3: (" & @ScriptLineNumber & ") : URL=" & _WD_Action($sSession, 'url') & @CRLF)
331331

@@ -402,7 +402,7 @@ Func DemoElements()
402402
FileWrite($hFileOpen, $bDecode)
403403
FileClose($hFileOpen)
404404

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"]')
406406
If @error Then Return SetError(@error, @extended)
407407

408408
Sleep(2000)
@@ -430,10 +430,20 @@ EndFunc ;==>DemoElements
430430
Func DemoScript()
431431
Local $sValue
432432

433+
; JavaScript example with arguments
433434
$sValue = _WD_ExecuteScript($sSession, "return arguments[0].second;", '{"first": "1st", "second": "2nd", "third": "3rd"}', Default, $_WD_JSON_Value)
434435
ConsoleWrite("wd_demo.au3: (" & @ScriptLineNumber & ") : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF)
435436

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)
437447
ConsoleWrite("wd_demo.au3: (" & @ScriptLineNumber & ") : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF)
438448

439449
; 2022-03-23 This website no longer exists
@@ -524,7 +534,7 @@ EndFunc ;==>DemoAlerts
524534
Func DemoFrames()
525535
Local $sElement, $bIsWindowTop
526536

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"]')
528538
If @error Then Return SetError(@error, @extended)
529539

530540
Local $iFrameCount = _WD_GetFrameCount($sSession)
@@ -637,7 +647,7 @@ Func DemoWindows()
637647

638648
_WD_NewTab($sSession)
639649
$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")]')
641651
If @error Then Return SetError(@error, @extended)
642652

643653
; Get window coordinates

0 commit comments

Comments
 (0)