Home > Language Reference > Web Functions > ExistHTMLElement

ExistHTMLElement

The ExistHTMLElement checks the existence of the specified web element within the current web page.

Usage

For advanced users, it allows to check first if an HTML element is there before using it.

Syntax

ret=ExistHTMLElement(<html_descriptor>)

Parameters

<html_descriptor>, string, HTML descriptor of the HTML element to test. Use Spy tool for generating the <html_descriptor> parameter.

Return value

Ret, numeric return code.  If the element exists within the current web page, the function returns 1. If it does not exist, the function returns 0. If there is no previous UsePage or StartBrowser lines, the function returns 0. 

Remarks

ExistHTMLELement function does not check if a UsePage has been done before, or if the element to test has finished to load. So a UsePage  statement must be executed before using ExistHTMLElement: the UsePage makes the automatic synchronization and so the line after the UsePage will be executed only when all the elements on the page are loaded.

If a web page contains multiple frames, and if you need to check that an update is finished in a specific frame, you can use ExistHTMLELement in a loop to test if one element is now there which tells that the frame has been updated.

Examples

'Check if the html element WinTask is on the first page of the WinTask website.
StartBrowser("IE", "www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
ret=ExistHTMLElement("A[INNERTEXT= 'WinTask']")
msgbox(ret) 'returns 1
CloseBrowser()

'The function is case sensitive for the HTML descriptor unless you use #IgnoreHTMLCase = 1
StartBrowser("IE", "www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
ret=ExistHTMLElement("A[INNERTEXT= 'winTask']")
msgbox(ret) 'returns 0
CloseBrowser()

but

StartBrowser("IE", "www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
#IgnoreHTMLCase=1
ret=ExistHTMLElement("A[INNERTEXT= 'winTask']")
msgbox(ret) 'returns 1
CloseBrowser()
 

'Check if the html element WinTask is on the first page of the WinTask website.
StartBrowser("FF", "www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
ret=ExistHTMLElement("A[INNERTEXT= 'WinTask']")
msgbox(ret) 'returns 1
CloseBrowser()

'The function is case sensitive for the HTML descriptor unless you use #IgnoreHTMLCase = 1
StartBrowser("FF", "www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
ret=ExistHTMLElement("A[INNERTEXT= 'winTask']")
msgbox(ret) 'returns 0
CloseBrowser()

'but
StartBrowser("FF", "www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
#IgnoreHTMLCase=1
ret=ExistHTMLElement("A[INNERTEXT= 'winTask']")
msgbox(ret) 'returns 1
CloseBrowser()