Está en la página 1de 2

QTPWorld http://www.qtpworld.com/index.php?

cid=56

Login | Search QTPWorld.com

Chapters Parameterization
Upcoming Trainings
Parameterization is nothing but giving multiple Input/Test data to the test script.
QTP Interview Questions

VB Script - Part I Different ways to Parameterize:

VB Script - Part II 1. Input the Test data from External files.


VB Script - Part III
2. Input the Test data through Datatable.
Working with Files using FSO
3. Input Test data through loop statements.
Excel
4. Input Test data dynamically through interactive submission.
Actions

Functions Input the Test data from External files:


Difference between Action and Set myxl = createobject("excel.application")
Function
'Make sure that you have created an excel file before executing the script .
Parameterization 'Use the path of excel file in the below code.
'Also make sure that your excel file is in Closed state.
Object Repository
myxl.Workbooks.Open "D:\parameter.xls"
Descriptive Programming myxl.Application.Visible = true

Regular Expression '"Sheet1" is the name of Sheet in Excel file "qtp.xls" where data needs to be entered .
set mysheet = myxl.ActiveWorkbook.Worksheets("Sheet1")
Error Handling & Recovery
Scenario 'contents of sheet1
'Uname Pwd
Output Values '------------ ------------
'qtpworld.com qtp
Database Connections 'admin qtp
' qtp
Automation Object Model 'admin
'abcd abcd
Synchronization
'Launch Gmail
Environment Variables Systemutil.Run "iexplore.exe","http:\\www.gmail.com"

XML Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync

Outlook

Reporting Defect Input the Test data through Datatable:

'Insert username and Password in the datatable sheet "Global" under column "Username" and "Password"

'contents of Global Sheet


Contact Us 'Username Password
'------------- ------------
'qtpworld.com qtp
info@qtpworld.com 'admin qtp
' qtp
+91- 9886477710 'admin
'abcd abcd

'Get the max used range of the datasheet "Global"


row=datatable.GetSheet("Global").GetRowCount

'Launch gmail.com
Systemutil.Run "iexplore.exe","http:\\www.gmail.com"

Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync

'Make sure whenever you parameterize through datatable you do the following ,
'1. go to File ->Settings ->Run
'2.On the right side panel , Under "Data Table iterations" select the first option that is "Run one iterat

'Loop to read all the data in the datasheet "Global"


For Drow= 1 to row

Input Test data through loop statements:

'parameterize using loop value


For orderno=1 to 10

'Login to sample Qtp flight application and keep the main window open.
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

'Parameterize orderno using the loop value


Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set orderno
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

1 of 2 1/29/2016 8:24 AM
QTPWorld http://www.qtpworld.com/index.php?cid=56

Next

Input Test data dynamically through interactive submission:

'Launch gmail.com
Systemutil.Run "iexplore.exe","http:\\www.gmail.com"

Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync

'Allowing user to enter User name and Password three times during run time

For i = 1 to 3

'Allowing user to enter User name and Password


Username=Inputbox("Enter username")
Password=InputBox("Enter Password")

' Enter Email id in Username Field


Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Email"

'Enter password in Passowrd Field


Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:= Passwd"

Next

Copyright QTPWorld.com 2013 Home | Demo videos | Students | Training | FAQ's | Feedback | About Us Designed By WebZone

2 of 2 1/29/2016 8:24 AM

También podría gustarte