![]()
API Guide - Datatable |
Courses in c#, ruby, shell scripting, Software testing courses and more
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Class | WET::DataTable |
| In: |
Datatable.rb
|
| Parent: | Object |
This version of WET has a very basic support for datatables.
The concept of datatables is used to test more than one set of data for the same test scripts. For example if you have a script that tests registration, then you can test the script for different categories of data without having to rewrite the scripts for each test. The most common way to use datatables is to retreive data from a table or spreadsheet. Datatables can either be store in a Excel spreadhseet or in an XML Format.
If storing in an Excel spreadsheet, thee rules for entering data in a datatable is as follows:
1) Data must be stored in the first worksheet of the specified excel spreadsheet.
2) The first row of the spreadsheet represents the data ‘fields’. For example, in an employee datatable, the fields may be a) Employee ID, b) First name, c) Last Name, d) Date of Birth and e) Date of joining.
3) The first column of the spreadsheet represents the category of data. During any testing assignment, one of the tester’s goal is to test the application for various categories of data. For example, you may want to test the employee database for a) first employee, b) last employee, c) Employee who barely qualifies as eligible to work, d) Employee who is a senior citizen, etc.,
If the Datatable is in an XML Format, then an example is : <data sheet=’sheetname>
<category name='general'>
<firstname>Me</firstname>
<lastname>Exists</lastname>
<employeeid>001</employeeid>
<age>34</age>
</category>
<category name='boundary'>
<firstname>New</firstname>
<lastname>Girl</lastname>
<employeeid>100</employeeid>
<age>26</age>
</category>
<!-- You can have many more categories here -->
</data>
There is also a utility to convert excel datatables to xml datatables.
Constructor that takes a file argument. The file is the full path to the datatable that will serve as the datatable.
Close the datatable corresponding to the database. Depending on the type of datatable, the action taken is different. For an xml datatable, nothing is done. For an excel sheet, the current worksheed is closed. If quit_app is passed as true, then the entire excel application is closed. You shouldn’t have to invoke this method directly. It is called by the main WetRunner script, before completing the current test.
Get the value of the item for the specified field If the optional cat parameter is specified, then the value for the filed for that category of data is retreived. Otherwise the data for the current iteration’s cataegory is returned
Load the file which has the required data. The file can either be an excel in the specified format or an xml file with the correct schema.
Get the number of rows in the table. The number of rows also represents the different categories of data
Set the current datatable’s default category. This method is as a convenience method. Typically in a transaction there would be various test steps that work on the same category of data. For example, you could have a email login for different kinds of users. One of the kinds could be a ‘numeric’ id. You will have different values like,
Browser(...).TextField(..1).set Datatable.item('uid', 'numeric')
Browser(...).TextField(..2).set Datatable.item('passwd', 'numeric')
# and more like this
Instead of having to repeat the ‘numeric’ category for every test step you could initially set the category to ‘numeric’ and then invoke the Datatable.item(…) using only the field name (uid / passwd)
| 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. |