Skip to content

Commit e38ae80

Browse files
Danp2mlipok
andauthored
Update wd_demo (#267)
* DemoScript -- Comment out last example * Update image xpath * Update target within frame * http > https (#268) Co-authored-by: Michał Lipok <mlipok@users.noreply.github.com>
1 parent 00e8c16 commit e38ae80

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

wd_demo.au3

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Func DemoTimeouts()
300300
Local $oJSON = Json_Decode($sResponse)
301301
Local $sTimouts = Json_Encode(Json_Get($oJSON, "[value]"))
302302

303-
_WD_Navigate($sSession, "http://google.com")
303+
_WD_Navigate($sSession, "https://google.com")
304304

305305
; Set page load timeout
306306
_WD_Timeouts($sSession, '{"pageLoad":2000}')
@@ -309,21 +309,21 @@ Func DemoTimeouts()
309309
_WD_Timeouts($sSession)
310310

311311
; This should timeout
312-
_WD_Navigate($sSession, "http://yahoo.com")
312+
_WD_Navigate($sSession, "https://yahoo.com")
313313

314314
; Restore initial settings
315315
_WD_Timeouts($sSession, $sTimouts)
316316
EndFunc ;==>DemoTimeouts
317317

318318
Func DemoNavigation()
319-
_WD_Navigate($sSession, "http://google.com")
319+
_WD_Navigate($sSession, "https://google.com")
320320
ConsoleWrite("- #" & @ScriptLineNumber & " : URL=" & _WD_Action($sSession, 'url') & @CRLF)
321321

322-
_WD_NewTab($sSession, Default, Default, "http://yahoo.com")
322+
_WD_NewTab($sSession, Default, Default, "https://yahoo.com")
323323
ConsoleWrite("- #" & @ScriptLineNumber & " : URL=" & _WD_Action($sSession, 'url') & @CRLF)
324324

325-
; _WD_Navigate($sSession, "http://yahoo.com")
326-
_WD_NewTab($sSession, True, Default, 'http://bing.com', 'width=200,height=200')
325+
; _WD_Navigate($sSession, "https://yahoo.com")
326+
_WD_NewTab($sSession, True, Default, 'https://bing.com', 'width=200,height=200')
327327
ConsoleWrite("- #" & @ScriptLineNumber & " : URL=" & _WD_Action($sSession, 'url') & @CRLF)
328328

329329
_WD_Attach($sSession, "google.com", "URL")
@@ -337,7 +337,7 @@ EndFunc ;==>DemoNavigation
337337
Func DemoElements()
338338
Local $sElement, $aElements, $sValue, $sButton, $sResponse, $bDecode, $hFileOpen
339339

340-
_WD_Navigate($sSession, "http://google.com")
340+
_WD_Navigate($sSession, "https://google.com")
341341

342342
; Locate a single element
343343
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector)
@@ -395,7 +395,7 @@ Func DemoElements()
395395
FileWrite($hFileOpen, $bDecode)
396396
FileClose($hFileOpen)
397397

398-
_WD_Navigate($sSession, "http://demo.guru99.com/test/simple_context_menu.html")
398+
_WD_Navigate($sSession, "https://demo.guru99.com/test/simple_context_menu.html")
399399

400400
Sleep(2000)
401401

@@ -428,13 +428,14 @@ Func DemoScript()
428428
$sValue = _WD_ExecuteScript($sSession, "dslfkjsdklfj;", '{}', Default, $_WD_JSON_Value)
429429
ConsoleWrite("- #" & @ScriptLineNumber & " : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF)
430430

431-
$sValue = _WD_ExecuteScript($sSession, "return $.ajax({url:'http://hosting105782.a2f0c.netcup.net/test.php',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});", Default, $_WD_JSON_Value)
432-
ConsoleWrite("- #" & @ScriptLineNumber & " : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF)
431+
; 2022-03-23 This website no longer exists
432+
;$sValue = _WD_ExecuteScript($sSession, "return $.ajax({url:'https://hosting105782.a2f0c.netcup.net/test.php',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});", Default, $_WD_JSON_Value)
433+
;ConsoleWrite("- #" & @ScriptLineNumber & " : ERROR=" & @error & " $sValue = " & $sValue & " _WD_LastHTTPResult = " & _WD_LastHTTPResult() & @CRLF)
433434
EndFunc ;==>DemoScript
434435

435436
Func DemoCookies()
436437
ConsoleWrite("- #" & @ScriptLineNumber & " : WD: Navigating:" & @CRLF)
437-
_WD_Navigate($sSession, "http://google.com")
438+
_WD_Navigate($sSession, "https://google.com")
438439

439440
ConsoleWrite("- #" & @ScriptLineNumber & " : WD: Get all cookies:" & @CRLF)
440441
Local $sAllCookies = _WD_Cookies($sSession, 'getall')
@@ -535,9 +536,7 @@ Func DemoFrames()
535536
; changing context to first sub frame
536537
_WD_FrameEnter($sSession, $sElement)
537538

538-
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='w3loginbtn']")
539-
_WD_ElementAction($sSession, $sButton, 'click')
540-
_WD_LoadWait($sSession, 2000)
539+
_WD_LinkClickByText($sSession, "Not Sure Where")
541540

542541
_WD_FrameLeave($sSession)
543542
$bIsWindowTop = _WD_IsWindowTop($sSession)
@@ -554,7 +553,7 @@ EndFunc ;==>DemoFrames
554553
Func DemoActions()
555554
Local $sElement, $sAction
556555

557-
_WD_Navigate($sSession, "http://google.com")
556+
_WD_Navigate($sSession, "https://google.com")
558557
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector)
559558
ConsoleWrite("- #" & @ScriptLineNumber & " : $sElement = " & $sElement & @CRLF)
560559

@@ -588,14 +587,14 @@ Func DemoActions()
588587
EndFunc ;==>DemoActions
589588

590589
Func DemoDownload()
591-
_WD_Navigate($sSession, "http://google.com")
590+
_WD_Navigate($sSession, "https://google.com")
592591

593592
; Get the website's URL
594593
Local $sUrl = _WD_Action($sSession, 'url')
595594

596595
; Find the element
597-
Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img[@id='hplogo']")
598-
596+
Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img[@alt='Google']")
597+
599598
If @error <> $_WD_ERROR_Success Then
600599
; Try alternate element
601600
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='hplogo']//img")
@@ -611,19 +610,19 @@ Func DemoDownload()
611610
; Download the file
612611
_WD_DownloadFile($sUrl, @ScriptDir & "\testimage.png")
613612

614-
_WD_DownloadFile("http://www.google.com/notexisting.jpg", @ScriptDir & "\testimage2.jpg")
613+
_WD_DownloadFile("https://www.google.com/notexisting.jpg", @ScriptDir & "\testimage2.jpg")
615614
EndIf
616615
EndFunc ;==>DemoDownload
617616

618617
Func DemoWindows()
619618
Local $sResponse, $hFileOpen, $sHnd1, $sHnd2, $bDecode, $oWRect
620619

621620
$sHnd1 = '{"handle":"' & _WD_Window($sSession, "window") & '"}'
622-
_WD_Navigate($sSession, "http://google.com")
621+
_WD_Navigate($sSession, "https://google.com")
623622

624623
_WD_NewTab($sSession)
625624
$sHnd2 = '{"handle":"' & _WD_Window($sSession, "window") & '"}'
626-
_WD_Navigate($sSession, "http://yahoo.com")
625+
_WD_Navigate($sSession, "https://yahoo.com")
627626

628627
; Get window coordinates
629628
$oWRect = _WD_Window($sSession, 'rect')

0 commit comments

Comments
 (0)