WebElementExists

Top  Previous  Next

×V4.1Ø

S

A

W

WS

ü

Syntax -

If WebElementExists <Element Identifier> [<Timeout>] ...

       Where:

               <Element Identifier> is a valid web element identifier as described in Identifying an Element.

               <Timeout> is a integer or a variable that contains an integer.

 

Description:

This comparison operator is used to determine if the element defined by <Element Identifier> appears on the web page.  Checking for the existence of an element is useful in determining that the script is executing on the correct page and prevents an error if the element does not exist.  This operator also allows the script to determine the behavior in the case that the element does not exist.

The optional <timeout> parameter allows the user to define a delay (in milliseconds) that the script will wait if the element is not present immediately.  If the element appears sooner, the script will proceed.  If the element does not appear after the delay, then the script will follow the logic defined in the IF statement.  If this parameter is not defined, then EMUE will wait for the element to appear for a period of time defined by WebElementTimeout before evaluating the IF statement.

 

Note: When using this command in IE, elements may return true even if they are not visible. When using in Chrome, elements will return false if they are not visible.

 

Soarian SmartUI: Yes

Chrome: Yes

 

Sample 1:

       The following IF statement will look for the existence of a specific table cell on the page whose title is "Check Patient In."

If WebElementExists "Browser=Main:sframeInner->wellFrame->tabWell7:Tablecell,Title=Check Patient In,INDEX=1" Then

       ClickWebElement "Browser=Main:sframeInner->wellFrame->tabWell7:Tablecell,Title=Check Patient In,INDEX=1"

       GoTo CheckForError

Else

       LogLine "Element not found, it does not exist.  Please advise."

       Goto Error

EndIf

 

Sample 2:

       The following COMPLEX IF statement will look up to 5000 milliseconds for the existence of a specific table cell on the page whose title is "Check Patient In."

If (WebElementExists("Browser=Main:sframeInner->wellFrame->tabWell7:Tablecell,Title=Check Patient In,INDEX=1", 5000)) Then

       ClickWebElement "Browser=Main:sframeInner->wellFrame->tabWell7:Tablecell,Title=Check Patient In,INDEX=1"

       GoTo CheckForError

Else

       LogLine "Element not found, it does not exist.  Please advise."

       Goto Error

EndIf

 

See Also:

Identifying an Element

WaitForWebPageCompletion

WaitForWebElementGoTo

WaitForWebElement

WebElementTimeout

EnableSoarianSmartUI