![]()
API Guide - Table |
Courses in c#, ruby, shell scripting, Software testing courses and more
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Class | WET::WebTable |
| In: |
WebTable.rb
|
| Parent: | WebContainer |
Class that represents a Web Table.This class is a child of Watir’s table.It also provided some additional methods to better manage a table.A table is a container.You can use the various creators provided by other containers like Browser or Frame.For example you could say,#..Table(..).Image(…)#.
Check the WebContainer document for details about the container methods.
HTML Tables on a web page can be controlled in WET using the Table object.WET Tables are full blown containers whose child objects can be retreived.
| container | [R] |
This is to initialize a Table.
The syntax to get the reference of a Table is :
Container.Table("name:=value")
Where
Container is a Browser, Frame, Table or any other container that can hold HTML elements as its children.
name is the name of the attribute to be checked.
value is the value of that attribute.
Browser('title:=Controls').Table('id:=tbl001')
The commonly used attributes to identify an Image are:
id The HTML id attribute of the table
text The text of this table. The text of the table is the aggregate of the cell's text.
Get the Row from the table whose properties match the specified arguments.It can be very handy to be able to get a row.For example,you could have a table of employees in which employee ID is the first column,the other columns have other data pertaining to the employee.To check various details about an employee,you could retreive the row whose text starts with the employee ID and confirm that all other details in that row match the required employees details.
The typical parameters use to retreive a row are:
text - Text displayed in the table
index
Check to see if the table actually exists on the page.If the table actually does exist,then prints out a success message in the test report.If it doesn’t exist,then it prints out a failure in the report. One example of using this check is immediately after performing ‘add’ operations.For example,after adding a new user,you may want to check that the user link actually does exist.
Check to see if the table *does not* exist on the page.If the table does not exist,then prints out a success message in the test report.If it actually does exit,then it prints out a failure in the report. One example of using this check is immediately after performing ‘delete’ operations.For example,after deleting ‘abc’,you may want to check that the user link for ‘abc’ has been deleted.
Verifies that the text displayed in the Table matches the text which is searched .If the table’s text matches the search_text,then a success message is printed in the test report.Otherwise,a failure is printed out in the report. The search_text parameter can either be a string literal (to do an exact match)or a regular expression.
This command is used to check that a particular text is not displayed in the table. This is usually used in negative test cases.This checks if the expected text does not match the text of the table. If the check is successful,that is,the table’s text does not match the expected text,then a success is printed in the test report.If the check fails,then a failure is printed in the test report.
Get the number of columns in the table. The number of columns also represents the number of fields .
Get the number of rows in the table. The number of rows also represents the different categories of data
Find a Button with the specified properties, The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The common properties used to identify a button are :
Find a Web checkbox with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a checkfield are:
displayed to the left of the checkbox.
Find a Web File with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a File are:
text displayed to the left of the file.
Find an IFrame with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a Textarea are:
Find an Image with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The common properties for an image are
Get a web Link with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
For a link the following are the commonly used properties:
Find a Web List with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a List are:
displayed to the left of the weblist
Find a Web radio button with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a radio button are:
label is considered to be the textimmediately after the radio.
Find a HTML Table with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties with which a table can be identified are:
info that is available about a table is the text contained in the table. The table's text is the aggregate of the contents of the cells of the table.
Find a Web textfield with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a textfield are:
displayed to the left of the textfield.
Find a Textarea with the specified properties. The properties are specified as name-value pairs using the syntax:
"property_name:=value"
The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"
The properties used to identify a Textarea are:
Get an element based on the tagname. This is useful for those cases where there is no predefined WET class for a particular tag but a scripter needs to use it.
For example if you want to get a <div> element whose id is ‘myId’, then you can say
element_by_tag_name("div", "id" => "myId")
Check to see if the object exists or not at runtime.
Returns true if the object exists, false if it doesn’t
| WET is a opensource automated web testing tool which uses Watir as the library to drive web pages. WET drives an IE Browser directly and so the automated testing done using WET is equivalent to how a user would drive the web pages. WET extends the scripting abilities of Watir and also offers the convenience of recorders. It is licensed under LGPL and BSD style open source licenses. |