Check whether error pop up exists or not .If exists then capture that popup and click ok on that error popup
SystemUtil.Run “C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe”
Dialog(“Login”).WinEdit(“Agent Name:”).Set “venkatesh”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4c0616cda83a5c9f88633cdaff4c044c”
Dialog(“Login”).WinButton(“OK”).Click
dialog(“Login”).Dialog(“Flight Reservations”).CaptureBitmap “d:\login.bmp”
bexists=Dialog(“Login”).Dialog(“Flight Reservations”).Exist(2)
If bexists Then
smsg=Dialog(“Login”).Dialog(“Flight Reservations”).GetVisibleText
reporter.ReportEvent micFail,”Login”,smsg
Dialog(“Login”).Dialog(“Flight Reservations”).WinButton(“OK”).Click
Dialog(“Login”).WinButton(“Cancel”).Click
exittest
End If
Run Reusable and Non reusable actions in qtp
Action1:
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 “venkatesh”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4c0616cda83a5c9f88633cdaff4c044c”
Dialog(“Login”).WinButton(“OK”).Click
bexists=Dialog(“Login”).Dialog(“Flight Reservations”).Exist(2)
If bexists Then
smsg=Dialog(“Login”).Dialog(“Flight Reservations”).GetVisibleText
reporter.ReportEvent micFail,”Login”,smsg
Dialog(“Login”).Dialog(“Flight Reservations”).WinButton(“OK”).Click
Dialog(“Login”).WinButton(“Cancel”).Click
End If
runaction “Action3″,oneiteration
Action2
msgbox “welcome to action2″
Reusable Action3
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 “venkatesh”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4c06513879e8c9aae96f878ebd40924cb403de52″
Dialog(“Login”).WinEdit(“Password:”).Type micReturn
Window(“Flight Reservation”).Close
1.How to give inputs from the global sheet—
This example is under descriptive programming
2.Give different search keywords at google and search using qtp
Set ie=createobject(“internetexplorer.application”)
ie.navigate(“http://www.google.co.in/”)
ie.visible=true
Browser(“title:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).Set DataTable(“search_keywords”,dtGlobalSheet)
Browser(“title:=Google”).Page(“title:=Google”).WebButton(“value:=Google Search”).Click
Browser(“opentitle:=Google”).Close
How to import/export excel from global sheet in qtp
Goto Global Sheet..Right Click—File–Import/Export
Create an excel and put results into the excel using qtp
Set xl= CreateObject(“Excel.application”)
xl.Visible = True
xl.Workbooks.add
a=15
b=20
If a>b Then
xl.Cells(1,1).Value = a
xl.Cells(1,2).value=”PASS”
Reporter.ReportEvent micDone,”a is bigger”, a
Else
xl.Cells(1,1).Value = b
xl.Cells(1,2).value=”FAIL”
Reporter.ReportEvent micFail ,”b is bigger” , b
End If
Open excel and put results in the excel
Set xl= CreateObject(“Excel.application”)
set wb=xl.workbooks.open(“d:/sample2.xls”)
Set ws=wb.worksheets(1)
‘xl.Visible = True
‘xl.Workbooks.add
a=15
b=20
If a>b Then
ws.Cells(1,1).Value =”a is bigger”
ws.Cells(1,2).value=”PASS”
Reporter.ReportEvent micDone,”a is bigger”, a
Else
ws.Cells(1,1).Value = “b is bigger”
ws.Cells(1,2).value = “FAIL”
ws.cells(1,2).font.bold=true
ws.cells(1,2).font.size=12
ws.Cells(1,2).font.colorindex=50
Reporter.ReportEvent micFail ,”b is bigger” , b
End If
wb.save
wb.close
Set ws=nothing
Set wb=nothing
Set xl=nothing
Recent Comments