Skip to content

Commit 9bab41d

Browse files
authored
_WD_WaitElement: Allow check for not visible (#390)
1 parent b02205b commit 9bab41d

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

wd_helper.au3

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Global Enum _
5252
$_WD_OPTION_Visible = 1, _
5353
$_WD_OPTION_Enabled = 2, _
5454
$_WD_OPTION_Element = 4, _
55-
$_WD_OPTION_NoMatch = 8
55+
$_WD_OPTION_NoMatch = 8, _
56+
$_WD_OPTION_Hidden = 16
5657

5758
Global Enum _
5859
$_WD_OPTION_Standard, _
@@ -338,7 +339,8 @@ EndFunc ;==>_WD_LinkClickByText
338339
; |$_WD_OPTION_None (0) = No optional feature processing
339340
; |$_WD_OPTION_Visible (1) = Confirm element is visible
340341
; |$_WD_OPTION_Enabled (2) = Confirm element is enabled
341-
; |$_WD_OPTION_NoMatch (8) = Confirm element not found
342+
; |$_WD_OPTION_NoMatch (8) = Confirm element is not found
343+
; |$_WD_OPTION_Hidden (16) = Confirm element is not visible
342344
; Return values .: Success - Element ID returned by web driver.
343345
; Failure - "" (empty string) and sets @error to one of the following values:
344346
; - $_WD_ERROR_Exception
@@ -363,12 +365,14 @@ Func _WD_WaitElement($sSession, $sStrategy, $sSelector, $iDelay = Default, $iTim
363365
If $iTimeout = Default Then $iTimeout = $_WD_DefaultTimeout
364366
If $iOptions = Default Then $iOptions = $_WD_OPTION_None
365367

366-
Local $bVisible = BitAND($iOptions, $_WD_OPTION_Visible)
367-
Local $bEnabled = BitAND($iOptions, $_WD_OPTION_Enabled)
368-
Local $bCheckNoMatch = BitAND($iOptions, $_WD_OPTION_NoMatch)
368+
Local Const $bVisible = BitAND($iOptions, $_WD_OPTION_Visible)
369+
Local Const $bEnabled = BitAND($iOptions, $_WD_OPTION_Enabled)
370+
Local Const $bNoMatch = BitAND($iOptions, $_WD_OPTION_NoMatch)
371+
Local Const $bHidden = BitAND($iOptions, $_WD_OPTION_Hidden)
369372

370-
; Other options aren't valid if No Match option is supplied
371-
If $bCheckNoMatch And $iOptions <> $_WD_OPTION_NoMatch Then
373+
; Other options aren't valid if No Match or Hidden option is supplied
374+
If ($bNoMatch And $iOptions <> $_WD_OPTION_NoMatch) Or _
375+
($bHidden And $iOptions <> $_WD_OPTION_Hidden) Then
372376
$iErr = $_WD_ERROR_InvalidArgue
373377
Else
374378
__WD_Sleep($iDelay)
@@ -391,16 +395,16 @@ Func _WD_WaitElement($sSession, $sStrategy, $sSelector, $iDelay = Default, $iTim
391395
; Exit loop if unexpected error occurs
392396
ExitLoop
393397

394-
ElseIf $iErr = $_WD_ERROR_NoMatch And $bCheckNoMatch Then
398+
ElseIf $iErr = $_WD_ERROR_NoMatch And $bNoMatch Then
395399
; if element wasn't found and "no match" option is active
396400
; exit loop indicating success
397401
$iErr = $_WD_ERROR_Success
398402
ExitLoop
399403

400-
ElseIf $iErr = $_WD_ERROR_Success And Not $bCheckNoMatch Then
404+
ElseIf $iErr = $_WD_ERROR_Success And Not $bNoMatch Then
401405
; if element was found and "no match" option isn't active
402-
; check $bVisible and $bEnabled options
403-
If $bVisible Then
406+
; check other options
407+
If $bVisible Or $bHidden Then
404408
$bIsVisible = _WD_ElementAction($sSession, $sElement, 'displayed')
405409

406410
If @error Then
@@ -417,11 +421,16 @@ Func _WD_WaitElement($sSession, $sStrategy, $sSelector, $iDelay = Default, $iTim
417421
EndIf
418422
EndIf
419423

420-
If $bIsVisible And $bIsEnabled Then
424+
Select
425+
Case $bHidden
426+
If Not $bIsVisible Then ExitLoop
427+
428+
Case $bIsVisible And $bIsEnabled
421429
ExitLoop
422-
Else
430+
431+
Case Else
423432
$sElement = ''
424-
EndIf
433+
EndSelect
425434
EndIf
426435

427436
If (TimerDiff($hWaitTimer) > $iTimeout) Then

0 commit comments

Comments
 (0)