Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AutoIt Snippet - _IEWaitForTagText
; #FUNCTION# ====================================================================================================================
; Name ..........: _IEWaitForTagText
; Description ...: Waits for a HTML tag to appear with the specified text
; Syntax ........: _IEWaitForTagText($oObject, $sTagName, $sTagText[, $iTimeout = 0[, $bNoError = True]])
; Parameters ....: $oObject - Object related to IE (Any Window, Frame, IFrame or any DOM object).
; $sTagName - Name of the HTML tag (p, img, tr, etc).
; $sTagText - The (inner) text of the tag to wait for.
; $iTimeout - [optional] Timeout for the wait in milliseconds. Default is 0 (No timeout).
; $bNoError - [optional] Temporarily disable IE errors messages in the console. Default is True.
; Return values .: Success: The DOM element's object
; Failure: False and @error is set to 1
; Author ........: Damon Harris (TheDcoder)
; Remarks .......: 1. Failure is impossible if $iTimeout is set to 0
; 2. This is how $bNoError works:
; * If $bNoError is True, then _IEErrorNotify(False) is called and _IEErrorNotify(True) is called after the wait.
; * If $bNoError is True and _IEErrorNotify() is False, nothing will be changed.
; * If $bNoError is False, nothing will be changed.
; Related .......: _IELoadWait
; Link ..........:
; Example .......: _IEWaitForTagText($oIE, "p", "logout")
; ===============================================================================================================================
Func _IEWaitForTagText($oObject, $sTagName, $sTagText, $iTimeout = 0, $bNoError = True)
Local $oTags, $hTimer, $sText, $bTurnOnNotify = False
If Not $iTimeout = 0 Then $hTimer = TimerInit()
If $bNoError And _IEErrorNotify() Then
$bTurnOnNotify = True
$oTags = _IETagNameGetCollection($oObject, $sTagName)
For $oTag In $oTags
$sText = _IEPropertyGet($oTag, "innertext")
If @error Then ContinueLoop
If ($sText = $sTagText) Then
If $bTurnOnNotify Then _IEErrorNotify(True)
Return $oTag
Until ($iTimeout = 0) ? False : (TimerDiff($hTimer) >= $iTimeout)
If $bTurnOnNotify Then _IEErrorNotify(True)
Return SetError(1, 0, False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.