4
4
Local Enum $eFireFox = 0 , _
5
5
$eChrome
6
6
7
- Local $aTestSuite [][2 ] = [[" TestTimeouts" , False ], [" TestNavigation" , False ], [" TestElements" , False ], [" TestScript" , True ], [" TestCookies" , False ], [" TestAlerts" , True ]]
7
+ Local $aTestSuite [][2 ] = [[" TestTimeouts" , False ], [" TestNavigation" , False ], [" TestElements" , True ], [" TestScript" , False ], [" TestCookies" , False ], [" TestAlerts" , False ]]
8
8
9
- Local Const $_TestType = $eFireFox
9
+ Local Const $_TestType = $eChrome
10
10
Local $sDesiredCapabilities
11
11
Local $iIndex
12
12
Local $sSession
@@ -22,9 +22,10 @@ Switch $_TestType
22
22
23
23
EndSwitch
24
24
25
- _WDStartup()
25
+ _WD_Startup()
26
+
27
+ $sSession = _WD_CreateSession($sDesiredCapabilities )
26
28
27
- $sSession = _WDCreateSession($sDesiredCapabilities )
28
29
29
30
For $iIndex = 0 To UBound ($aTestSuite , $UBOUND_ROWS ) - 1
30
31
If $aTestSuite [$iIndex ][1 ] Then
@@ -35,90 +36,92 @@ For $iIndex = 0 To UBound($aTestSuite, $UBOUND_ROWS) - 1
35
36
EndIf
36
37
Next
37
38
38
- _WDDeleteSession ($sSession )
39
- _WDShutdown ()
39
+ _WD_DeleteSession ($sSession )
40
+ _WD_Shutdown ()
40
41
41
42
42
43
Func TestTimeouts()
43
- _WDTimeouts ($sSession )
44
- _WDTimeouts ($sSession , ' {"pageLoad":2000}' )
45
- _WDTimeouts ($sSession )
44
+ _WD_Timeouts ($sSession )
45
+ _WD_Timeouts ($sSession , ' {"pageLoad":2000}' )
46
+ _WD_Timeouts ($sSession )
46
47
EndFunc
47
48
48
49
Func TestNavigation()
49
- _WDNavigate ($sSession , " http://google.com" )
50
- ConsoleWrite (" URL=" & _WDAction ($sSession , ' url' ) & @CRLF )
51
- _WDAction ($sSession , " back" )
52
- ConsoleWrite (" URL=" & _WDAction ($sSession , ' url' ) & @CRLF )
53
- _WDAction ($sSession , " forward" )
54
- ConsoleWrite (" URL=" & _WDAction ($sSession , ' url' ) & @CRLF )
55
- ConsoleWrite (" Title=" & _WDAction ($sSession , ' title' ) & @CRLF )
50
+ _WD_Navigate ($sSession , " http://google.com" )
51
+ ConsoleWrite (" URL=" & _WD_Action ($sSession , ' url' ) & @CRLF )
52
+ _WD_Action ($sSession , " back" )
53
+ ConsoleWrite (" URL=" & _WD_Action ($sSession , ' url' ) & @CRLF )
54
+ _WD_Action ($sSession , " forward" )
55
+ ConsoleWrite (" URL=" & _WD_Action ($sSession , ' url' ) & @CRLF )
56
+ ConsoleWrite (" Title=" & _WD_Action ($sSession , ' title' ) & @CRLF )
56
57
EndFunc
57
58
58
- ; _WDWindow($sSession, 'frame', '{"id":null}')
59
-
59
+ ; _WDWindow($sSession, 'frame', '{"id":nullelse
60
60
Func TestElements()
61
- _WDNavigate ($sSession , " http://google.com" )
62
- $sElement = _WDFindElement ($sSession , $_WD_LOCATOR_ByXPath , " //input[@id='lst-ib1']" )
61
+ _WD_Navigate ($sSession , " http://google.com" )
62
+ $sElement = _WD_FindElement ($sSession , $_WD_LOCATOR_ByXPath , " //input[@id='lst-ib1']" )
63
63
64
64
If @error = $_WD_ERROR_NoMatch Then
65
- $sElement = _WDFindElement ($sSession , $_WD_LOCATOR_ByXPath , " //input[@id='lst-ib']" )
65
+ $sElement = _WD_FindElement ($sSession , $_WD_LOCATOR_ByXPath , " //input[@id='lst-ib']" )
66
66
EndIf
67
67
68
- $sElement2 = _WDFindElement ($sSession , $_WD_LOCATOR_ByXPath , " //div/input" , ' ' , True )
68
+ $aElements = _WD_FindElement ($sSession , $_WD_LOCATOR_ByXPath , " //div/input" , ' ' , True )
69
69
70
- _WDElementAction($sSession , $sElement , ' value' , " testing 123" )
71
- _WDElementAction($sSession , $sElement , ' text' )
72
- _WDElementAction($sSession , $sElement , ' clear' )
73
- _WDElementAction($sSession , $sElement , ' value' , " abc xyz" )
74
- _WDElementAction($sSession , $sElement , ' text' )
75
- _WDElementAction($sSession , $sElement , ' clear' )
76
- _WDElementAction($sSession , $sElement , ' value' , " fujimo" )
77
- _WDElementAction($sSession , $sElement , ' text' )
78
- _WDElementAction($sSession , $sElement , ' click' )
70
+ _ArrayDisplay($aElements )
79
71
80
- _WDElementAction($sSession , $sElement , ' Attribute' , ' test' )
72
+ _WD_ElementAction($sSession , $sElement , ' value' , " testing 123" )
73
+ _WD_ElementAction($sSession , $sElement , ' text' )
74
+ _WD_ElementAction($sSession , $sElement , ' clear' )
75
+ _WD_ElementAction($sSession , $sElement , ' value' , " abc xyz" )
76
+ _WD_ElementAction($sSession , $sElement , ' text' )
77
+ _WD_ElementAction($sSession , $sElement , ' clear' )
78
+ _WD_ElementAction($sSession , $sElement , ' value' , " fujimo" )
79
+ _WD_ElementAction($sSession , $sElement , ' text' )
80
+ _WD_ElementAction($sSession , $sElement , ' click' )
81
81
82
- $sElement = _WDFindElement($sSession , $_WD_LOCATOR_ByXPath , " //input[@id='lst-ib']" )
83
- $sValue = _WDElementAction($sSession , $sElement , ' property' , ' value' )
82
+ _WD_ElementAction($sSession , $sElement , ' Attribute' , ' text' )
83
+
84
+ $sElement = _WD_FindElement($sSession , $_WD_LOCATOR_ByXPath , " //input[@id='lst-ib']" )
85
+ $sValue = _WD_ElementAction($sSession , $sElement , ' property' , ' value' )
84
86
85
87
ConsoleWrite (' value = ' & $sValue & @CRLF )
88
+
86
89
EndFunc
87
90
88
91
Func TestScript()
89
- _WDExecuteScript ($sSession , " return arguments[0].second;" , ' {"first": "1st", "second": "2nd", "third": "3rd"}' )
90
- _WDAlert ($sSession , ' Dismiss' )
92
+ _WD_ExecuteScript ($sSession , " return arguments[0].second;" , ' {"first": "1st", "second": "2nd", "third": "3rd"}' )
93
+ _WD_Alert ($sSession , ' Dismiss' )
91
94
EndFunc
92
95
93
96
Func TestCookies()
94
- _WDNavigate ($sSession , " http://google.com" )
95
- _WDCookies ($sSession , ' Get' , ' NID' )
97
+ _WD_Navigate ($sSession , " http://google.com" )
98
+ _WD_Cookies ($sSession , ' Get' , ' NID' )
96
99
EndFunc
97
100
98
101
Func TestAlerts()
99
- ConsoleWrite (' Alert Detected => ' & _WDAlert ($sSession , ' status' ) & @CRLF )
100
- _WDExecuteScript ($sSession , " alert('testing 123')" )
101
- ConsoleWrite (' Alert Detected => ' & _WDAlert ($sSession , ' status' ) & @CRLF )
102
- ConsoleWrite (' Text Detected => ' & _WDAlert ($sSession , ' gettext' ) & @CRLF )
103
- _WDAlert ($sSession , ' sendtext' , ' new text' )
104
- ConsoleWrite (' Text Detected => ' & _WDAlert ($sSession , ' gettext' ) & @CRLF )
105
- _WDAlert ($sSession , ' Dismiss' )
102
+ ConsoleWrite (' Alert Detected => ' & _WD_Alert ($sSession , ' status' ) & @CRLF )
103
+ _WD_ExecuteScript ($sSession , " alert('testing 123')" )
104
+ ConsoleWrite (' Alert Detected => ' & _WD_Alert ($sSession , ' status' ) & @CRLF )
105
+ ConsoleWrite (' Text Detected => ' & _WD_Alert ($sSession , ' gettext' ) & @CRLF )
106
+ _WD_Alert ($sSession , ' sendtext' , ' new text' )
107
+ ConsoleWrite (' Text Detected => ' & _WD_Alert ($sSession , ' gettext' ) & @CRLF )
108
+ _WD_Alert ($sSession , ' Dismiss' )
106
109
107
110
EndFunc
108
111
109
112
110
113
Func SetupGecko()
111
- _WDOption (' Driver' , ' geckodriver.exe' )
112
- _WDOption (' DriverParams' , ' --log trace' )
113
- _WDOption (' Port' , 4444 )
114
+ _WD_Option (' Driver' , ' geckodriver.exe' )
115
+ _WD_Option (' DriverParams' , ' --log trace' )
116
+ _WD_Option (' Port' , 4444 )
114
117
115
118
$sDesiredCapabilities = ' {"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
116
119
EndFunc
117
120
118
121
Func SetupChrome()
119
- _WDOption (' Driver' , ' chromedriver.exe' )
120
- _WDOption (' Port' , 9515 )
121
- _WDOption (' DriverParams' , ' --log-path=' & @ScriptDir & ' \chrome.log' )
122
+ _WD_Option (' Driver' , ' chromedriver.exe' )
123
+ _WD_Option (' Port' , 9515 )
124
+ _WD_Option (' DriverParams' , ' --log-path=' & @ScriptDir & ' \chrome.log' )
122
125
123
126
$sDesiredCapabilities = ' {"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
124
127
EndFunc
0 commit comments