Separating test data from business using a DataTable

Source: Internet
Author: User

When the basic consistent business process, the need to test complex test data, you can parameterize the test data, while using a DataTable to achieve test data and business separation, this method in my current project is applied in many places, feel super convenient, now the work of the application to summarize:

1. Create a local Excel to store the parameter names and values of the test data.

2. Set Excel path in QTP

Open qtp->file->setting->environment->variable (select user-defined), click ... Settings such as:

By setting the LocalPath, the test data table does not need to be placed in a uniform path, increasing the flexibility of Excel path. The implementation of any computer running scripts can be set by QTP LocalPath to the local Excel test data table in advance.

The specific code is as follows:

DATASTR = Environment ("TestDir") & "\login.xls"

Datatable.addsheet ("Login")
Datatable.importsheet datastr, "login", "Login"
RowCount1 = Datatable.getsheet ("Login"). GetRowCount
Systemutil.run "C:\Program files\internet Explorer\iexplore. EXE "," http:\\deliver.sinosure.com.cn "
For i = 1 to RowCount1
DataTable. Setcurrentrow (i)
user = Datatable.value ("User", "Login")
PWD = Datatable.value ("pwd", "Login")
Browser ("China export Credit insurance company. *"). Page ("China Export Credit insurance company. *"). Webedit ("username"). Set User
Browser ("China export Credit insurance company. *"). Page ("China Export Credit insurance company. *"). Webedit ("password"). Set pwd
Browser ("China export Credit insurance company. *"). Page ("China Export Credit insurance company. *"). Webbutton ("Login"). Click
Browser ("China export Credit insurance company. *"). Page ("China Export Credit insurance company. *"). Webbutton ("logout"). Click

Next

The test data table is as follows:

PS:QTP an Excel document that supports XLS suffixes and does not support the xlsx suffix

Separating test data from business using a DataTable

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.