QTP:
1) File-Settings-----Show the test settings
Options screen comes
The above window is a global setting
Test Parameters:
Step Generator:
Call Existing Action:
Recovery Manager
Handle popups etc.
1) Popup recovery
2) Object state
3) Test run error
4) Application crash
1) Popup Recovery
Object state recovery
Web based :
Open links from a file:
'Description Object
Set all_link=Browser("Google").Page("Google").ChildObjects(olink)
Set f1=CreateObject("Scripting.FileSystemObject')
Set f2 =f1.createtextfile("d:\qtp\mylinkfile.txt",True)
' create objectbrowser
Set obrowser=description.create
obrowser("micclass").value="Browser"
Set opage=description.create
opage("micclasee").value="Page"
Write the links to a file:
Set f1=createobject("scripting.filesystemobject")
Set f2 =f1.createtextfile("d:\qtp\mylinkfile.txt",True)
Set olink=description.Create
olink("micclass").value="Link"
Set all_link=Browser("Google").Page("Google").ChildObjects(olink)
msgbox all_link.count
For i=1 to all_link.count
hhref = all_link(i-1).getROProperty("href")
v_name=all_link(i-1).getroproperty("name")
f2.writeline(hhref &","&v_name&",")
Next
'Read a file
Set f3 = f1.Opentextfile("d:\qtp\mylink.txt",1)
Do while f2.atendofline <> True
v_href = split(f2.Readline,",")
Browser(obrowser).Navigate(v_href(0))
Browser(obrowser).page(opage).Sync
v_title = Browser(obrowser).GetROProperty("title")
Loop
Storing info in datatable:
rowglobal = DataTable.GetRowCount()
rowaction1=datatable.GetSheet("Action1").getrowcount()
rowaction2=datatable.GetSheet("Action2").getrowcount()
msgbox rowglobal
msgbox rowaction1
msgbox rowaction2
a=1
For i=1 to rowglobal
datatable.SetCurrentRow(i)
val1=datatable.Value("glo","Global")
msgbox val1
For j=1 to rowaction1
DataTable.GetSheet("Action1").setcurrentrow(j)
val2=DataTable.Value("Act1","Action1")
msgbox val2
For k=1 to rowaction2
datatable.GetSheet("Action2").setcurrentrow(k)
val3=datatable.Value("Act2","Action2")
DataTable.GetSheet("Action3").SetCurrentRow(a)
DataTable.value("Result","Action3") = val1+val2+val3
a=a+1
Next
Next
Next
DataTable.ExportSheet "d:\qtp\myexpgfile.xls","Action3"
and so on………
Result:
Object Model
Read an excelsheet:
Set f1=createobject("scripting.filesystemobject")
Set f2=f1.opentetfile("d:\qtp\RunLogic.csv",1)
var1=f2.readline
If var1(2) = "N" Then
exitaction
End If
Smart Identification
click configure
click add/remove and select nativeclass
After this record fax number scenario and run the script.The script works.
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "name"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No.
43").ActiveX("MaskEdBox").Type "1321321321321"
Window("Flight Reservation").Dialog("Fax Order No. 43").WinButton("Send").Click
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Activate
The speed at which the object is recognized is very slow .
SetTO Property:
Window("Flight Reservation").ActiveX("MaskEdBox").Type "1111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "name"
Window("Flight Reservation").WinButton("Insert Order").Click
wait(8)
faxno=Window("Flight Reservation").WinEdit("Order No:").GetVisibleText
'Window("Flight Reservation").WinEdit("Order No:").GetROProperty "text"
v_no="Fax Order No. "+faxno
Window("Flight Reservation").Dialog("Fax Order No. 42").SetTOProperty "text", v_no
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No.
42").ActiveX("MaskEdBox").Type "42434234244"
Window("Flight Reservation").Dialog("Fax Order No. 42").WinButton("Send").Click
Window("Flight Reservation").WinButton("Button").Click
GetROProperty: same thing with getroproperty
Window("Flight Reservation").ActiveX("MaskEdBox").Type "1111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "name"
Window("Flight Reservation").WinButton("Insert Order").Click
wait(8)
'faxno=Window("Flight Reservation").WinEdit("Order No:").GetVisibleText
faxno=Window("Flight Reservation").WinEdit("Order No:").GetROProperty ("text")
v_no="Fax Order No. "+faxno
Window("Flight Reservation").Dialog("Fax Order No. 42").SetTOProperty "text", v_no
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No.
42").ActiveX("MaskEdBox").Type "42434234244"
Window("Flight Reservation").Dialog("Fax Order No. 42").WinButton("Send").Click
Window("Flight Reservation").WinButton("Button").Click
Shell scripting
{} curly braces are for special characters
'Shell scripting
' Any dos command can be done from here
Set myshell=createobject("Wscript.shell")
myshell.run"calc"
wait(2)
myshell.sendkeys"1{+}"
wait(1)
myshell.sendkeys"2"
wait(1)
myshell.sendkeys"{Enter}"
Database output value:
Window("Flight Reservation").Restore
Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "soumen"
Window("Flight Reservation").WinButton("Insert Order").Click
wait(8)
Window("Flight Reservation").WinEdit("Order No:").Output CheckPoint("Order No:")
DataTable("query",dtGlobalSheet) = "Select * from orders where order_number="&
DataTable("Order_No",dtGlobalSheet)
Window("Flight Reservation").WinButton("Button").Click
DbTable("DbTable").Output CheckPoint("DbTable")