Single Post

Header

Sunday, September 30, 2012

Small Examples in QTP




1.Record and Play Back in qtp (Login and Close)

SystemUtil.Run “C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe”,”",”C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\”,”open”
Dialog(“Login”).WinEdit(“Agent Name:”).Set “abcd”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4c03551c45cb9c6ce024f12617d6e7f461936ba5″
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Close

2. How to create excel file to store results for qtp

Set  xl= CreateObject(“Excel.application”)
xl.Visible = True
xl.Workbooks.add
a=15
b=20

If a>b  Then
xl.ActiveSheet.Cells(1,1).Value = a
Reporter.ReportEvent micDone,”a is bigger”, a
Else
xl.ActiveSheet.Cells(1,1).Value = b
Reporter.ReportEvent  micDone ,”b is bigger” , b
End If

3. How to store Store results in excel using qtp
‘ This is one of the method for importing excel in qtp

set xl=createobject(“excel.application”)
set wb=xl.workbooks.open(“D:\myexcel.xls”)
a=15
b=20

If a>b  Then
wb.ActiveSheet.Cells(1,1).Value = a
Reporter.ReportEvent micDone,”a is bigger”, a
Else
wb.ActiveSheet.Cells(1,1).Value = b
Reporter.ReportEvent  micDone ,”b is bigger” , b
End If

wb.save
wb.close

set wb=nothing
set xl=nothing

4.How to use global and Local Data Sheets in qtp

In Blank Test Case by default one action would be created.
Then write the below code in Action1–>Expert View

gd=DataTable(“Names_Global”, dtGlobalSheet)
ld=DataTable(“College”, dtLocalSheet)
msgbox gd&”_”&ld

Goto insert —>Call to new action and then it would create action2
Then write the below code in Action2–>Expert View

gd=DataTable(“Names_Global”,dtGlobalSheet)
ld=DataTable(“Number”,dtLocalSheet)
msgbox gd&”_”&ld

Put any data in Global ,Action1 and Action2 sheets and then execute.
In the above Names_Global,College and Number are the user defined coloumn names in the
corresponding sheets

1.If we do not give application path

object did not find error

2.For
textboxes---WinEdit
buttons-----Winbutton
menu--------Winmenu
dropdownlist---WinComboBox

3.What is logical name

it is a unique name under which specific physical description of a respective object to store


No comments:

Post a Comment