24
24
; AutoIt Version : v3.3.14.3
25
25
; ==============================================================================
26
26
#cs
27
+ V0.1.0.13
28
+ - Fixed: Remove unsupported locator constants
29
+ - Fixed: Return value of _WD_WaitElement
30
+ - Changed: Add support for 'displayed' option in _WD_ElementAction (BigDaddyO)
31
+ - Changed: Add $lVisible parameter to _WD_WaitElement
32
+ - Changed: $_WD_DEBUG now defaults to $_WD_DEBUG_Info
33
+
27
34
V0.1.0.12
28
35
- Changed: Modified _WD_NewTab with timeout parameter
29
36
- Fixed: Correctly set @error in _WD_ExecuteScript
@@ -148,6 +155,11 @@ Global Const $_WD_LOCATOR_ByTagName = "tag name"
148
155
149
156
Global Const $_WD_DefaultTimeout = 10000 ; 10 seconds
150
157
158
+ Global Enum _
159
+ $_WD_DEBUG_None = 0 , _ ; No logging to console
160
+ $_WD_DEBUG_Error , _ ; Error logging to console
161
+ $_WD_DEBUG_Info ; Full logging to console
162
+
151
163
Global Enum _
152
164
$_WD_ERROR_Success = 0 , _ ; No error
153
165
$_WD_ERROR_GeneralError , _ ; General error
@@ -189,7 +201,7 @@ Global $_WD_OHTTP = ObjCreate("winhttp.winhttprequest.5.1")
189
201
Global $_WD_HTTPRESULT ; Result of last WinHTTP request
190
202
191
203
Global $_WD_ERROR_MSGBOX = True ; Shows in compiled scripts error messages in msgboxes
192
- Global $_WD_DEBUG = True ; Trace to console and show web driver app
204
+ Global $_WD_DEBUG = $_WD_DEBUG_Info ; Trace to console and show web driver app
193
205
194
206
#EndRegion Global Variables
195
207
@@ -217,7 +229,7 @@ Func _WD_CreateSession($sDesiredCapabilities = '{}')
217
229
Local $sResponse = __WD_Post($_WD_BASE_URL & " :" & $_WD_PORT & " /session" , $sDesiredCapabilities )
218
230
Local $iErr = @error
219
231
220
- If $_WD_DEBUG Then
232
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
221
233
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
222
234
EndIf
223
235
@@ -261,7 +273,7 @@ Func _WD_DeleteSession($sSession)
261
273
Local $sResponse = __WD_Delete($_WD_BASE_URL & " :" & $_WD_PORT & " /session/" & $sSession )
262
274
Local $iErr = @error
263
275
264
- If $_WD_DEBUG Then
276
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
265
277
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
266
278
EndIf
267
279
@@ -294,7 +306,7 @@ Func _WD_Status()
294
306
Local $sResponse = __WD_Get($_WD_BASE_URL & " :" & $_WD_PORT & " /status" )
295
307
Local $iErr = @error
296
308
297
- If $_WD_DEBUG Then
309
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
298
310
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
299
311
EndIf
300
312
@@ -339,7 +351,7 @@ Func _WD_Timeouts($sSession, $sTimeouts = '')
339
351
340
352
Local $iErr = @error
341
353
342
- If $_WD_DEBUG Then
354
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
343
355
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
344
356
EndIf
345
357
@@ -375,7 +387,7 @@ Func _WD_Navigate($sSession, $sURL)
375
387
376
388
Local $iErr = @error
377
389
378
- If $_WD_DEBUG Then
390
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
379
391
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
380
392
EndIf
381
393
@@ -449,7 +461,7 @@ Func _WD_Action($sSession, $sCommand, $sOption = '')
449
461
450
462
EndSwitch
451
463
452
- If $_WD_DEBUG Then
464
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
453
465
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
454
466
EndIf
455
467
@@ -580,7 +592,7 @@ Func _WD_Window($sSession, $sCommand, $sOption = '')
580
592
581
593
EndSwitch
582
594
583
- If $_WD_DEBUG Then
595
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
584
596
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
585
597
EndIf
586
598
@@ -660,7 +672,7 @@ Func _WD_FindElement($sSession, $sStrategy, $sSelector, $sStartElement = "", $lM
660
672
EndIf
661
673
EndIf
662
674
663
- If $_WD_DEBUG Then
675
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
664
676
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
665
677
EndIf
666
678
@@ -751,7 +763,7 @@ Func _WD_ElementAction($sSession, $sElement, $sCommand, $sOption = '')
751
763
752
764
EndSwitch
753
765
754
- If $_WD_DEBUG Then
766
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
755
767
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
756
768
EndIf
757
769
@@ -788,7 +800,7 @@ Func _WD_ExecuteScript($sSession, $sScript, $sArguments = "[]")
788
800
789
801
$sResponse = __WD_Post($_WD_BASE_URL & " :" & $_WD_PORT & " /session/" & $sSession & " /execute/sync" , $sData )
790
802
791
- If $_WD_DEBUG Then
803
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
792
804
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
793
805
EndIf
794
806
@@ -871,7 +883,7 @@ Func _WD_Alert($sSession, $sCommand, $sOption = '')
871
883
Return SetError (__WD_Error($sFuncName , $_WD_ERROR_InvalidDataType , " (Dismiss|Accept|GetText|SendText|Status) $sCommand=>" & $sCommand ), 0 , " " )
872
884
EndSwitch
873
885
874
- If $_WD_DEBUG Then
886
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
875
887
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
876
888
EndIf
877
889
@@ -912,7 +924,7 @@ Func _WD_GetSource($sSession)
912
924
$sResult = Json_Get($sJSON , " [value]" )
913
925
EndIf
914
926
915
- If $_WD_DEBUG Then
927
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
916
928
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
917
929
EndIf
918
930
@@ -983,7 +995,7 @@ Func _WD_Cookies($sSession, $sCommand, $sOption = '')
983
995
Return SetError (__WD_Error($sFuncName , $_WD_ERROR_InvalidDataType , " (GetAll|Get|Add|Delete) $sCommand=>" & $sCommand ), " " )
984
996
EndSwitch
985
997
986
- If $_WD_DEBUG Then
998
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
987
999
ConsoleWrite ($sFuncName & ' : ' & $sResponse & @CRLF )
988
1000
EndIf
989
1001
@@ -1084,7 +1096,7 @@ Func _WD_Startup()
1084
1096
1085
1097
Local $sCommand = StringFormat (' "%s" %s ' , $_WD_DRIVER , $_WD_DRIVER_PARAMS )
1086
1098
1087
- If $_WD_DEBUG Then
1099
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1088
1100
ConsoleWrite (" _WDStartup: OS:" & @TAB & @OSVersion & " " & @OSType & " " & @OSBuild & " " & @OSServicePack & @CRLF )
1089
1101
ConsoleWrite (" _WDStartup: AutoIt:" & @TAB & @AutoItVersion & @CRLF )
1090
1102
ConsoleWrite (" _WDStartup: WD.au3:" & @TAB & $__WDVERSION & @CRLF )
@@ -1095,7 +1107,7 @@ Func _WD_Startup()
1095
1107
ConsoleWrite (' _WDStartup: ' & $sCommand & @CRLF )
1096
1108
EndIf
1097
1109
1098
- Local $pid = Run ($sCommand , " " , $_WD_DEBUG ? @SW_SHOW : @SW_HIDE )
1110
+ Local $pid = Run ($sCommand , " " , ( $_WD_DEBUG = $_WD_DEBUG_Info ) ? @SW_SHOW : @SW_HIDE )
1099
1111
1100
1112
If @error Then
1101
1113
Return SetError (__WD_Error($sFuncName , $_WD_ERROR_GeneralError , " Error launching web driver!" ), 0 , 0 )
@@ -1144,7 +1156,7 @@ Func __WD_Get($sURL)
1144
1156
Local Const $sFuncName = " __WD_Get"
1145
1157
Local $iResult , $sResponseText
1146
1158
1147
- If $_WD_DEBUG Then
1159
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1148
1160
ConsoleWrite ($sFuncName & ' : URL=' & $sURL & @CRLF )
1149
1161
EndIf
1150
1162
@@ -1169,7 +1181,7 @@ Func __WD_Get($sURL)
1169
1181
EndIf
1170
1182
EndIf
1171
1183
1172
- If $_WD_DEBUG Then
1184
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1173
1185
ConsoleWrite ($sFuncName & ' : StatusCode=' & $_WD_HTTPRESULT & " ; $sResponseText=" & $sResponseText & @CRLF )
1174
1186
EndIf
1175
1187
@@ -1208,7 +1220,7 @@ Func __WD_Post($sURL, $sData)
1208
1220
Local Const $sFuncName = " __WD_Post"
1209
1221
Local $iResult , $sResponseText , $iErr
1210
1222
1211
- If $_WD_DEBUG Then
1223
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1212
1224
ConsoleWrite ($sFuncName & ' : URL=' & $sURL & " ; $sData=" & $sData & @CRLF )
1213
1225
EndIf
1214
1226
@@ -1234,7 +1246,7 @@ Func __WD_Post($sURL, $sData)
1234
1246
EndIf
1235
1247
EndIf
1236
1248
1237
- If $_WD_DEBUG Then
1249
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1238
1250
ConsoleWrite ($sFuncName & ' : StatusCode=' & $_WD_HTTPRESULT & " ; ResponseText=" & $sResponseText & @CRLF )
1239
1251
EndIf
1240
1252
@@ -1267,7 +1279,7 @@ Func __WD_Delete($sURL)
1267
1279
1268
1280
Local $iResult , $sResponseText
1269
1281
1270
- If $_WD_DEBUG Then
1282
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1271
1283
ConsoleWrite ($sFuncName & ' : URL=' & $sURL & @CRLF )
1272
1284
EndIf
1273
1285
@@ -1292,7 +1304,7 @@ Func __WD_Delete($sURL)
1292
1304
EndIf
1293
1305
EndIf
1294
1306
1295
- If $_WD_DEBUG Then
1307
+ If $_WD_DEBUG = $_WD_DEBUG_Info Then
1296
1308
ConsoleWrite ($sFuncName & ' : StatusCode=' & $_WD_HTTPRESULT & " ; ResponseText=" & $sResponseText & @CRLF )
1297
1309
EndIf
1298
1310
@@ -1325,19 +1337,27 @@ EndFunc ;==>__WD_Delete
1325
1337
; ===============================================================================================================================
1326
1338
Func __WD_Error($sWhere , $i_WD_ERROR , $sMessage = " " )
1327
1339
Local $sMsg
1328
- Sleep (200 )
1329
1340
1330
- $sMsg = $sWhere & " ==> " & $aWD_ERROR_DESC [$i_WD_ERROR ]
1341
+ Switch $_WD_DEBUG
1342
+ Case $_WD_DEBUG_None
1331
1343
1332
- If $sMessage <> " " Then
1333
- $sMsg = $sMsg & " : " & $sMessage
1334
- EndIf
1344
+ Case $_WD_DEBUG_Error
1345
+ If $i_WD_ERROR <> $_WD_ERROR_Success Then ContinueCase
1335
1346
1336
- ConsoleWrite ($sMsg & @CRLF )
1337
- If @Compiled Then
1338
- If $_WD_ERROR_MSGBOX And $i_WD_ERROR < 6 Then MsgBox (16 , " WD_Core.au3 Error:" , $sMsg )
1339
- DllCall (" kernel32.dll" , " none" , " OutputDebugString" , " str" , $sMsg )
1340
- EndIf
1347
+ Case $_WD_DEBUG_Info
1348
+ $sMsg = $sWhere & " ==> " & $aWD_ERROR_DESC [$i_WD_ERROR ]
1349
+
1350
+ If $sMessage <> " " Then
1351
+ $sMsg = $sMsg & " : " & $sMessage
1352
+ EndIf
1353
+
1354
+ ConsoleWrite ($sMsg & @CRLF )
1355
+
1356
+ If @Compiled Then
1357
+ If $_WD_ERROR_MSGBOX And $i_WD_ERROR < 6 Then MsgBox (16 , " WD_Core.au3 Error:" , $sMsg )
1358
+ DllCall (" kernel32.dll" , " none" , " OutputDebugString" , " str" , $sMsg )
1359
+ EndIf
1360
+ EndSwitch
1341
1361
1342
1362
Return $i_WD_ERROR
1343
1363
EndFunc ; ==>__WD_Error
0 commit comments