Data Driven testing in QTP

How to test Login module with different username and password by using Data Driven testing in QTP.

Questions by anurag.sinha80

Showing Answers 1 - 9 of 9 Answers

Paramaterization is the answer.
Add two columns with userid and password heading in Global or local datatable
and insert specific user ids and password , three to four rows.

browser.page.webedit("userid").set = datatable("Global","userid")
browser.page.webedit("password").set = datatable("Global","password")

It will run three to four times the whole login script .

  Was this answer useful?  Yes

prasanti

  • Apr 2nd, 2012
 

Here is the script below for gmail log in page.

Code
  1. SystemUtil.Run "iexplore.exe"

  2. Browser("micclass:=Browser").Navigate"http://www.gmail.com"

  3. Browser("title:=Gmail","micClass:=Gmail").page("title:=Gmail").Webedit("micClass:=Webedit","html tag:=INPUT","name:=UserName").Set Datatable("UserName",1)

  4. Browser("title:=Gmail","micClass:=Gmail").page("title:=Gmaill").Webedit("micClass:=Webedit","html tag:=INPUT","name:=Password").Set Datatable("UserName",1)

  5. Browser("title:=Gmail").Page("title:=Gmail").Webbutton("name:=Login").Click

  6. Browser("title:=Gmail").Close


  Was this answer useful?  Yes

We can use Data Table for this purpose (i.e. either local Data Table or global Data Table).
We can put datas to the Data Table under columns declared as username and password (i.e. column names are given manually, they are not predefined).
We can also directly import data from external sheet, database or .txt file

Syntax :

browser.page.webedit("username").set = datatable("Global","username")
browser.page.webedit("password").set = datatable("Global","password")

Note: The parameter name (i.e. username or password) given in the script should match with column name of the sheet from where data is retrieved and action name (i.e. here Global) should match with the sheet name for successful run of the script.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions