Web Functional Testing > Function Reference > Adding HTML Check Functions

Adding HTML Check Functions

Tags:  

Description : HTML Check functions are used to validate the property of a HTML element present in the web page. There are functions to validate the property of each type of HTML element in the web page.

Where the HTML Check Functions can be used ?

Following is the scenario where HTML Check Functions can be used,
  • To validate the default value of the HTML element when the webpage is freshly loaded.
  • HTML element can be validated for its current value.
  • Web Page can be validated for the title of the document.
  • Web page can be validated for the presence of a text in the page.
  • HTML element can be validated for the style applied.
  • Message shown in the alert window can be validated.

How to insert HTML Check Functions in the script ?

HTML Check functions should be inserted while recording the script. During recording to insert HTML check for an element follow the below steps :
  • Click the "Insert Checkpoint" link available above the script editor
  • In the Functions Combo select the appropriate check function  and click on "Click to Proceed" link.
  • Select the appropriate element from the web page for which the validation is to be added.
  • If you are inserting the checkpoint in normal recording mode, then appropriate element function with element details will be shown in the Function Generator.
  • If you are inserting the checkpoint in the expert recording mode, then checkElementProperty function will be selected and in the Function Generator.
  • Choose the property needs to be validated from the property combo and provide the expected value for the property.
  • After providing the above details click on "Paste" to add the check function in to the script.
Following are the various check functions available to validate HTML element during playback,


editCheckInfo

 Function Description:

 Use this function to validate the property of the textbox / textarea. Properties such as ID, name, value can be validated using this function.

How to Define:

 editCheckInfo("Object ID", "property","Expected_Value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

          Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

editCheckInfo("Object ID", "property","value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "name" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

Example:

editCheckInfo("yourname_1","value","Mary")

 Return Values:

 0 for Success

1 for Failure

Top


buttonCheckInfo

 Function Description:

 Use this function to validate the property of button element. Following are the HTML elements that can be validated using this function :

    • INPUT button
    • INPUT checkbox
    • INPUT radio
    • INPUT reset
    • INPUT submit
    • BUTTON

Properties such as name, id, value, checked, defaultCheck, innertext can be validated using this function.

How to Define:

 buttonCheckInfo("Object ID", "property","Expected_Value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

          Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

buttonCheckInfo("Object ID", "property","value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "name" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

 Example:

 buttonCheckInfo("language_3","status","true")

 Return Values:

0 for Success

1 for Failure

 Top


linkCheckInfo

Function Description:

 Using this function you can validate the property of an anchor element in the webpage. The properties such as innertext, id, class, innerhtml, name can be validated using this function.

How to Define:

 linkCheckInfo("Object ID", "property","expected_value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

linkCheckInfo("Object ID", "property","expected_value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "innertext" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

 Example:

 linkCheckInfo("www.adventnet.com", "innertext","www.adventnet.com")

Return Values:

 0 for Success

1 for Failure

Top


selectCheckInfo

 Function Description:

 Use this function to validate the property of select combo element. Properties such as id, name, selected items, all items, selected count, all count can be validated using this function.

 How to Define:

 selectCheckInfo("Object ID", "property","Expected_Value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

          Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

selectCheckInfo("Object ID", "property","value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "name" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

 Example:

 selectCheckInfo("department_1","selecteditems","Sales")

Return Values:

 0 for Success

1 for Failure

Top


imageCheckInfo

 Function Description:

 Use this function to validate the propery of an image element. Properties such as src, id, name can be validated using this function.

How to Define:

 imageCheckInfo("Object ID", "property","Expected_Value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Image Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

          Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

imageCheckInfo("Object ID", "property","value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "src" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

Example:

 imageCheckInfo("http://www.adventnet.com/images/free-edition-appmanager.gif","source", "http://www.adventnet.com/images/free-edition-appmanager.gif")

 Return Values:

 0 for Success

1 for Failure

Top


listCheckInfo

 Function Description:

 Use this function to validate the property of LI / DIV / SPAN elements. Properties such as name, id, innertext etc., can be validated using this function.

How to Define:

 listCheckInfo("Object ID","property","Expected_Value")

ObjectID =  ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

listCheckInfo("Object ID", "property","value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "name" and property value is the value to be overwritten during playback to identify the element properly.

Example:

 listCheckInfo("li1", "name","listelement1")

Return Values:

0 for Success

1 for Failure

Top


 checkCellValueAt

Function Description:

 Using this function you can validate the cell value of any given Table cell.

How to Define:

 checkCellValueAt("Element ID","cellvalue","Expected_Value")

ElementID =  ID generated by QEngine linked to the GUI Map File.

cellvalue = The property name "cellvalue" to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

          Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

checkCellValueAt("Element ID","cellvalue","expected_value", "<property_name>","<property_value>") where property name is the identification property such as "id" or "firstCellValue" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

Example:

 checkCellValueAt ("S.No","cellvalue","Product")

Return Values:

 0 for Success

1 for Failure

Top


 checkCellValueAtNM

Function Description:

 Using this function you can validate the cell value of any given Table cell. NM denotes No Map. This function does not require Map file. All the needed identification data will be part of the function arguments.

How to Define:

 checkCellValueAtNM("Table_Property","Table_Property_Value","TableIndex","Row_Index","Column_Index","cellvalue","Expected_Value")

Table_Property = Table identification property such as firstcellvalue or table id using which the table can  be identified.

Table_Property_Value = The Value for the above specified property which should be matched.

TableIndex = Occurrence of the table with similar identification property.

Row_Index = Index of the table row whose value should be retrieved.

Column_Index = Index of the table column whose value should be retrieved.

cellvalue = The property name "cellvalue" to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

This function can be added directly from the Function Generated.  If you are recording in Expert Mode and adding check point for checkCellValueAt, QEngine will automatically change the function name to checkCellValueAtNM.

 

Example:

 checkCellValueAtNM("tableid","cmp_table",1,6,2,"cellvalue","SDP","Test-001")

Return Values:

 0 for Success

1 for Failure

Top


styleCheckInfo

Function Description:

 Use this function to validate the style properties of the HTML Element.  Properties such as cursor, color, background-color, font, font-family, font-size, font-style, text-decoration, width, height, background-image and text-align can be validated using this function.

How to Define:

 styleCheckInfo("ElementID ","Property", "Expected_Value")

ElementID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

Handling Identification property Changes: Any of the identification property can be overrided in the above function call as stated below :

styleCheckInfo("Object ID", "property","value", "<property_name>","<property_value>") where property name is the identification property such as "id", "name" or "src" and property value is the value to be overwritten during playback to properly identify the element in the webpage.

 Example:

styleCheckInfo("Test Plans","font-style","normal")

 Return Values:

0 for Success

1 for Failure

Top


staticCheckInfo

 Function Description:

 Use this function to validate the Message text displayed in the alert / prompt / confirm javascript popup's.

How to Define:

 staticCheckInfo("Object ID","property","Expected_Value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched.

Example:

 staticCheckInfo("Static","value","Choose the communication type")

Return Values:

0 for Success

1 for Failure

Top


pageCheckInfo

 Function Description:

 Use this function to validate the properties of the webpage. Properties such as windowtitle,windowname,status, responsetime etc., can be validated using this function.

How to Define:

 pageCheckInfo("Object ID", "property","Expected_Value")

ObjectID = ID generated by QEngine linked to the GUI Map File.

Property = Required Property name to be checked.

Expected_Value = Expected Value of the above specified property to be matched. 

Example:

pageCheckInfo("AdventNet Payroll System Package - Form to Add Employee Details","windowtitle",

"AdventNet Payroll System Package - Form to Add Employee Details")

Return Values:

 0 for Success

1 for Failure

Top


webCheckText

 Function Description:

Use this function to validate the presence of text in the webpage displayed.  The search text can be validated for having configured prefix and suffix text.

How to Define:

webCheckText("search text", "prefix","suffix")

Example:

 webCheckText("Product","The","name")

 Return Values:

0 for Success

1 for Failure

Top


checkElementProperty

 Function Description:

 Use this function to validate any element in the web page. This function does not require map file entry for the element to be validated. The element identification property will be part of the function arguments. Supports regular expression in the identification property.

How to Define:

 checkElementProperty("Tag_Name","Property_Name","Property_Value",Index,"Required_Property","Expected_Value","Test_Case_ID","useRegEx")

          Tag_Name = Tag name of the element whose property needs to be validated.
          Property_Name = Element property name which should be used to identify the element in the web page.
          Property_Value = value for the above given Property_Name using which the elements in the web page will be identified.
          Index = Occurrence of the element with similar identification properties in the web page.
          Required_Property = Required property name which need to be validated.
          Expected_Value = Expected value of the above specified property to be matched.
          Test_Case_ID = Test case id that needs to be used for reporting in test case summary report.
          useRegEx = Whether to use regular expression for matching the element identification properties.

Example:

For example, in the below HTML code, to validate the option text available in the Department select box, enter the function as follows,

         checkElementProperty("SELECT","name","Department",1,"allitems","Accounts:-:Sales:-:HRD ","Test-001","false")

<tr>
<td style="text-align: right;"><span style="font-weight: bold;">Enter Your Department</span> </td>
<td>
<select multiple="multiple" name="Department">
        <option value="accounts">Acccounts</option>
        <option value="sales">Sales</option>
        <option value="hrd">HRD</option>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: top; text-align: right;"><span style="font-weight: bold;">Mode for Communication</span><br>
</td>
<td style="vertical-align: top;">
<select name="media" id="communication">
        <option>E-Mail</option>
        <option>Departmental Mail</option>
        <option>FAX</option>
        <option>Automated voice mail</option>
</select>
</td>
</tr>

 

Detailing the various

The first parameter tagName = SELECT

The second parameter propertyName = name 

The third parameter propertyValue = Department

The fourth parameter index = 1 since this the only select box with name Department.

The fiftth parameter propRequired = allitems this to fetch all the options available in the select box.

The sixth parameter expectedValue = "Accounts:-:Sales:-:HRD" these are the values present in the select box.

The seventh parameter case_id = Test-001 test case id used to report in the test case summary report

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

Return Values:

0 for Success

1 for Failure

Top


checkElementPropertyById

 Function Description:

 Use this function to validate any element in the web page. This function does not require map file entry for the element to be validated. If the element to be validated has valid id property, then provide the id property directly in the first parametr to identify the element in the web page.

How to Define:

 checkElementPropertyById("Element_Id","Reqd_Property","Match_Value","Case_Id",[Index,"Use_RegEx"])

          Element_Id = id property of the element to be identified
          Reqd_Property = Required property name which need to be validated.
          Match_Value = Expected value of the above specified property to be matched.
          Test_Case_ID = Test case id that needs to be used for reporting in test case summary report.
          Index (Optional argument)= Occurrence of the element with similar identification properties in the web page.
          useRegEx (Optional argument)= Whether to use regular expression for matching the element identification properties.

Example:

For example, in the below HTML code, to validate the option text available in the Communication select box, enter the function as follows,

         checkElementPropertyById("communication","allitems","E-Mail:-:Departmental Mail:-:FAX:-:Automated Voice Mail","Test-002",1,"false")

<tr>
<td style="text-align: right;"><span style="font-weight: bold;">Enter Your Department</span> </td>
<td>
<select multiple="multiple" name="Department">
        <option value="accounts">Acccounts</option>
        <option value="sales">Sales</option>
        <option value="hrd">HRD</option>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: top; text-align: right;"><span style="font-weight: bold;">Mode for Communication</span><br>
</td>
<td style="vertical-align: top;">
<select name="media" id="communication">
        <option>E-Mail</option>
        <option>Departmental Mail</option>
        <option>FAX</option>
        <option>Automated voice mail</option>
</select>
</td>
</tr>

Detailing the various

The first parameter Element_Id = communication

The second parameter propRequired = allitems this to fetch all the options available in the select box.

The third parameter expectedValue = "Accounts:-:Sales:-:HRD" these are the values present in the select box.

The fouth parameter case_id = Test-001 test case id used to report in the test case summary report

The fifth parameter index = 1 since this the only select box with id communication.

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

Return Values:

0 for Success

1 for Failure

Top



0 Comments  Show recent to old
Post a comment


 RSS of this page

Copyright © 2009, Zoho Corporation. All Rights Reserved.