Adding HTML General Functions


doesElementExists

 

Function Description:

 

To check whether the specified  HTML Element with the given tagname and matching property name and value exists. Supports regular expressions.

 

How to Define:

 

doesElementExists(tagName, propertyName, propertyValue, index, [regExpRequired])

 

Mandatory Parameters :
 

tagname = Tag name of the elements to be identified.

propertyname = Property to be matched.

propertyvalue = Property value to be matched,

index = Occurrence of the elements.

regExpRequired :

true - property value will be considered as a regular expression. To know the details of using regular expressions in property value, refer to the following link.

false - property value will be matched for equals condition.

 

Example:

 

For example, in the below HTML code to check whether the 2nd text element exists, enter the function as follows:

 

<TR>

<TD>text

</TD>

<TD><input type="text" name="userid" size="20" onclick="alertForAction('button name')" onmouseover="callMouseAction('mouseover',this);" onmouseout="callMouseAction('mouseout',this);"></TD>

<TD id="tablecell1">User ID<input type="text" name="userid" size="20"></TD>

<TD><input type="text" name="userid" size="20" id="useridid"></TD>

<TD><input type="text" name="userid" size="20" id="useridid"></TD>

<TD><input type="text" name="useridid" size="20"></TD>

<TD><input type="text" name="useridid" size="20" id="userid"></TD>

</TR>

 

doesElementExists("input", "type", "text", 2, "false")

 

In the above case,

 

The first parameter tagName = input

The second parameter propertyName = name

The third parameter propertyValue = userid

The fourth parameter index = 2 since the second text element has to be checked to see whether the element exists or not.

The fiftth parameter regExpRequired = false, since regular expression is not used.

 

You can also use regular expressions for the 3rd parameter (propertyValue).

regExpRequired accepts "true" or "false" to support regular expressions. To know the details of using the regular expressions, refer to the following link.

 

Return Values:

 

0 for Success

1 for Failure

 

Top


selectItemWithIndex

 

Function Description:

 

To select the item in the dropdown list based on the specified index value.

 

How to Define:

 

selectItemWithIndex("Element ID","Element index", waittime)

 

Example:

 

result =selectItemWithIndex("department_1",5,1))

 

Return Values:

 

0 for Success

1 for Failure

 

Top


fireEventOnElement

 

Function Description:

 

To invoke the specified event for the given HTML element.

 

How to Define:

 

fireEventOnElement("tagName", "propertyName", "propertyValue", index, "actionName", "actionValue", "useRegExp")

 

Mandatory Parameters :
 

tagname = Tag name of the element for which the specified event has to be fired.

propertyname = Property name to be matched.

propertyvalue = Property value to be matched. The property value can also be given as a dynamic property using regular expressions. i.e., when the properties in your HTML page changes each time the script is replayed.

index = Occurrence of the element in the HTML page.

actionName = Specify one of the action.

1. click - to click any element such as, button, image, anchor , etc.

2. doubleclick - to double click any element such as img, image button, etc.

3. mouseover - to fire mouseover over event on any element.

4. rightclick - to fire double click event on any element.

5. settext - to set the text in the text field, password or textarea element.

6. select - to select any option in the list element (either single or multiple).

actionValue = For setText and selectItem events, actionValue parameter is mandatory.

 

Optional Parameters :
 

useRegExp = Accepts true or false which determines whether to use regular expression or not.

If false, property value will be matched for equal condition. To know the details of using the regular expressions, refer to the following link.

 

Example:

 

For example, in the below HTML code, to fire the click action on the third button, enter the function as follows.

 

<TR>

<TD>button

</TD>

<TD><input type="button" value="butdup" name="but" onclick="alertForAction('button namedup')"></TD>

<TD><input type="button" value="butid" name="but" id="butid" onclick="alertForAction('button id')">/TD>

<TD><input type="button" value="butiddup" name="but" id="butid" onclick="alertForAction('button iddup')"></TD>

</TR>

 

fireEventOnElement("input", "name", "but", 3, "click", "","false")

 

In the above case,

 

The first parameter tagName = input

The second parameter propertyName = name

The third parameter propertyValue = but

The fourth parameter index = 3 since the third button has to be clicked.

The fiftth parameter actionName = click

The sixth parameter actionValue = "", since the value is applicable only for setText and selectItem actions.

The seventh parameter useRegExp = false, since regular expression is not used.

 

The above function will click the 3rd occurrence of the input button element in the HTML page.

 

Return Values:

 

0 for Success

1 for Failure

 

Top




Copyright © 1999, AdventNet Inc. All Rights Reserved.