Dynamic Functions : Function Index

Description : Dynamic functions can be used to identify an element / window in a webpage, whose identification properties need not present in the map file. i.e,  The element / window identification properties for the element / window that needs to be identified in the Web Page displayed will be sent in the arguments to the dynamic functions.

Where the Dynamic Functions can be used ?

Following is the scenario where the dynamic functions will be used,

How to insert dynamic functions in the script ?
Following are the various functions available in the Dynamic Functions category,
  1. closeDynamicWindow
  2. closeUnExpectedPopUp
  3. doesDialogWindowExists
  4. doesElementExists
  5. doesPopUpExists
  6. doesWindowExists
  7. fireEventOnElement
  8. fireEventOnChildElement
  9. getElementProperty
  10. getPopUpText
  11. getUnExpectedPopUpTitle
  12. setDynamicDialogWindow
  13. setDynamicWindow


closeUnExpectedPopUp

Function Description:

During playback, if any popup that was not encountered during recording, appears then it is called unexpected popup and you can close the same using this function.

How to Define:

 closeUnExpectedPopUp("Window Title",timeout)

 Example:

            unexpectedTitle =  getUnExpectedPopUpTitle()
            result =closeUnExpectedPopUp(unexpectedTitle,2)

 Return Values:

0 for Success

1 for Failure

 Top

doesElementExists

Function Description:

Using this function any HTML element can be verified for its existance in the webpage.


The Element will be identified based on the configured tagname , propertyname and propertyvalue.
The element properties are need not present in the GUI map file.

 How to Define:

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

Mandatory Parameters :

tagname = HTML tag name of the element to be identified.

propertyname = Identification property with which the element can be identified in the webpage

propertyvalue = Value for the identification property used to match the element in the webpage.

index = Occurrence of the element to match if there are more elements matching the above property name and value.

regExpRequired : If the above configured property value needs to be matched by applying the regular expression or not. To know the details of using regular expressions in property value, refer to the following link.

    true - match the property value with regular expression.

    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>


In the above HTML you can find there are two "input" element exist with the same name name="userid".


To check whether there is second occurence element exist in the page, use the below function call,

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


doesPopUpExists

Function Description:

Use this function to verify whether any popup (alert/prompt/confirm) window with the specified title exists during playback.

 How to Define:

 doesPopupExists("Title")

 Example:

 result =doesPopUpExists("Microsoft Internet Explorer")

The above will search for the popup window with title "Microsoft Internet Explorer" and return success if it is found.

 Return Values:

0 for Success

1 for Failure

 Top


fireEventOnElement

Function Description:

 Using this function, desired action can be initiated over the certain HTML element identified through the arguments to the function.  The element details need not present in the GUI map file.

 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 = Any attribute of the element with which the HTML element can be identified in the webpage.

propertyvalue = value for the above configured attribute of the HTML element

index = Occurrence of the element in the HTML page.  Default value is 1.

actionName = Specify any one of the action listed below,

    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. keypress - to fire key press action over the element.
    7. select - to select any option in the list element (either single or multiple).
            actionValue =  value for the above specified action name.
                     settext -  this will take value that needs to be filled in to input or textarea element.
                     keypress - this will take value of the Key ID for the key press that needs to be simulated.
                                        VK_RETURN - for Enter
                                        VK_SPACE - for Space bar
                                        VK_TAB - for TAB

                      selectitem /select - the option text that needs to be set selected in the identified combo box.
                                                   if you are having multi-select combo, then use ":-:" as the separator between the option items that needs to be set selected.


Optional Parameters :


useRegExp = Accepts true or false which determines whether to use regular expression or not to identify the HTML element in the webpage.
                      If set to true, the attribute value for identifying the element will be matched by applying the regular expression.

                      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 input button with the attribute "name = but" will be searched and third occurence of the button will be initiated with the action specified in the function call.

 Return Values:

0 for Success

1 for Failure

 Top


fireEventOnChildElement

Function Description:

 Using this function, desired action can be initiated over the certain child HTML element of the given parent HTML element identified through the arguments to the function.  The element details need not present in the GUI map file.

 How to Define:

        fireEventOnChildElement("tagName", "propertyName", "propertyValue", index,"childIdentifier", "actionName", "actionValue",   
                                                                     "childPropName","childPropValue","childIndex","childRegEx","useRegExp")

 Mandatory Parameters : 

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

propertyname = Any attribute of the element with which the HTML element can be identified in the webpage.

propertyvalue = value for the above configured attribute of the HTML element

index = Occurrence of the element in the HTML page.  Default value is 1.
childIdentifier = The Child Identifier to identify the child elements using index or property name.

    1. elemindex - to identify element based on the child element position in the child collection.
    2. elemprop - to identify element based on the child property name and value in the child collection.


actionName = Specify any one of the action listed below,

    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. keypress - to fire key press action over the element.
    7. select - to select any option in the list element (either single or multiple).
            actionValue =  value for the above specified action name.
                     settext -  this will take value that needs to be filled in to input or textarea element.
                     keypress - this will take value of the Key ID for the key press that needs to be simulated.
                                        VK_RETURN - for Enter
                                        VK_SPACE - for Space bar
                                        VK_TAB - for TAB

                      selectitem /select - the option text that needs to be set selected in the identified combo box.
                                                   if you are having multi-select combo, then use ":-:" as the separator between the option items that needs to be set selected.


Optional Parameters :


childPropName = Any attribute of the element with which the HTML element can be identified in the child collection.

childPropVal = value for the above configured attribute of the HTML element
childIndex = Occurrence of the element in the HTML page.  Default value is 1.

childRegEx = Accepts true or false which determines whether to use regular expression or not to identify the child element from the element collection.
useRegExp = Accepts true or false which determines whether to use regular expression or not to identify the HTML element in the webpage.
                      If set to true, the attribute value for identifying the element will be matched by applying the regular expression.

                      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.

<DIV name="custom">
<input type="text" size="20" />
<input type="checkbox" />
</DIV>


 fireEventOnChildElement("DIV", "name", "custom", 1, "elemindex","settext", "QEngine","NONE","NONE",1,"false","false")


 In the above case,

             The input textbox is identified from the child collection of the DIV element identified through given properties.

 Return Values:

0 for Success

1 for Failure




getElementProperty

Function Description:

Using this function, any desired property can be obtained of the certain HTML element identified through the arguments to the function.  The element details need not present in the GUI map file.

How to Define:

getElementProperty("tagName, "propertyName", "propertyValue","iIndex","propRequired", "useRegExp")


Mandatory Parameters : 

tagname = HTML tag name of the element from which the property has to be obtained.

propertyname = Any attribute of the element with which the HTML element can be identified in the webpage.

propertyvalue = value for the above configured attribute of the HTML element

          Index = Occurrence of the element in the HTML page.  Default value is 1.

          properRequired = the property whose value has to be obtained after identifying the element with the given identification details.

You can also use regular expressions for the 3rd parameter "property value" wherein useRegExp must be "true" to support regular expressions. By default, useRegExp is false. To know the details of using the regular expressions, refer to the following link.

Example:

For example, in the below HTML code, to get the value of the innertext say idlink for the third a href element, enter the function as follows.

<TR>

<TD>link

</TD>

<TD> <a href="http://autotest-server/" id="linkid" onclick="return alertForAction('link id')"><b>idlink</b></a></TD>

<TD> <a href="http://autotest-server/" id="linkid" onclick="return alertForAction('link iddup')"><b>idlink</b></a>

</TD>

<TD> <a href="http://autotest-server/" onclick="return alertForAction('link nci')"><b>linkid</b></a>

</TD>

<TD> <a href="http://autotest-server/" id="namelink" onclick="return alertForAction('link icn')"><b>idlink</b></a>

</TD>

</TR>

<TR>


result = getElementProperty("a", "id", "namelink", 3, "innertext","false")


In the above case,

                The anchor link with the attribute "id= namelink" will be searched with the index, and then the needed property "innertext" will be extracted from the element. The extracted property value will be returned as function return value.

Return Value:

Returns the property value as string.

 Top


getPopUpText

Function Description:

 Use this function to retrieve the message displayed in a popup window, which can be identified by the title given.

 How to Define:

 result =getPopUpText("<window_title>","<wait_time>")

window_title ->  Title of the popup window from which the message has to be retrieved.
wait_time -> maximum wait time after which the message has to be retrieved.

 Example:

result =getPopUpText("Microsoft Internet Explorer",6)

displayMessage(result)

 Return Values:

 String - The message displayed in the popup window.

 Top


getUnExpectedPopUpTitle

Function Description:

 During playback, if any popup that was not encountered during recording, appears then it is called unexpected popup. To read the title of the popup window, you can use this function.

 How to Define:

 result =getUnExpectedPopUpTitle()

 Example:

result =getUnExpectedPopUpTitle()

displayMessage(result)

 Return Values:

 String - The title of the popup window.

Top


 



Copyright © 1999, AdventNet Inc. All Rights Reserved.