// Function to Synchronize for a particular object//
Public function fnSynchronization(objName)
fnSynchronization = false
Dim intLoopStart
Dim intLoopwait
intLoopStart = 1
intLoopwait = 10
Set objName = objName
// waiting for the object to appear//
Do while intLoopStart <= intLoopwait
// wait for existance of that object//
If opbjName.Exist(1) then
fnSynchronization = true
Exit do
Else
intLoopStart = intLoopStart+1
End if
Loop
End Function
Showing posts with label QTP. Show all posts
Showing posts with label QTP. Show all posts
Wednesday, September 21, 2011
Verify the items exists in Drop down box
Public Function fnVerifyDroDownItems(objDropdown,strItemsToSearch)
Dim intItemsCount,intCounter,strItem,bInItemPresent
Dim arrItemsToSerach
fnVerifyDropDownItems = True
If (objDropdown.Exist = False) then
reporter.report micFail,"The Dropdown box '" & objDropdown.GetROProperty("name") & "' should Exist", "The Dropdown Box does not exist", "FAIL")
fnVerifyDropDownItems=False
Exit Function
End If
// Get count of items in dropdown //
intItemsCount = objDropdown.GetTOProperty("items count")
// Split the list items list based on comma(,)//
arrItemsToSearch = Split(strItemsToSearch, ",")
For intItems=0 to UBound(arrItemsToSearch)
blnItemPresent = False
// Loop through all items //
For intCounter=1 to intItemsCount
strItem = ""
// Get an item //
strItem = objDropdown.GetItem(intCounter)
// If the search item is present //
If (StrComp(Trim(strItem), Trim(arrItemsToSearch(intItems)), 1) = 0) Then
blnItemPresent = True
reporter.report micPass "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item exists in the dropdown box", "PASS")
Exit For
End If
Next
If (Not blnItemPresent) Then
reporter.report micFail , "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item does not exist in the dropdown box", "WARNING")
fnVerifyDropDownItems = False
End If
Next
End Function
Dim intItemsCount,intCounter,strItem,bInItemPresent
Dim arrItemsToSerach
fnVerifyDropDownItems = True
If (objDropdown.Exist = False) then
reporter.report micFail,"The Dropdown box '" & objDropdown.GetROProperty("name") & "' should Exist", "The Dropdown Box does not exist", "FAIL")
fnVerifyDropDownItems=False
Exit Function
End If
// Get count of items in dropdown //
intItemsCount = objDropdown.GetTOProperty("items count")
// Split the list items list based on comma(,)//
arrItemsToSearch = Split(strItemsToSearch, ",")
For intItems=0 to UBound(arrItemsToSearch)
blnItemPresent = False
// Loop through all items //
For intCounter=1 to intItemsCount
strItem = ""
// Get an item //
strItem = objDropdown.GetItem(intCounter)
// If the search item is present //
If (StrComp(Trim(strItem), Trim(arrItemsToSearch(intItems)), 1) = 0) Then
blnItemPresent = True
reporter.report micPass "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item exists in the dropdown box", "PASS")
Exit For
End If
Next
If (Not blnItemPresent) Then
reporter.report micFail , "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item does not exist in the dropdown box", "WARNING")
fnVerifyDropDownItems = False
End If
Next
End Function
fetch cell value from table
Dim X
Browser("S.O.S. Math - Mathematical").Page("S.O.S. Math - Mathematical").Frame("Frame").Check CheckPoint("Frame")
Browser("S.O.S. Math - Mathematical").Page("S.O.S. Math - Mathematical").Frame("Frame").WebElement("Class 1 to Class 12 Lessons,").FireEvent "onmouseover",718,13
Browser("S.O.S. Math - Mathematical").Page("S.O.S. Math - Mathematical").Link("A Trigonometric Table").Click 66,12
Browser("S.O.S. Math - Mathematical").Navigate "http://www.sosmath.com/tables/trigtable/trigtable.html"
Browser("S.O.S. Math - Mathematical").Page("Trig Table").Frame("Frame").Check CheckPoint("Frame_2")
Browser("S.O.S. Math - Mathematical").Page("Trig Table").Frame("Frame").Link("Class 1 to Class 12").FireEvent "onmouseover",42,1
Browser("S.O.S. Math - Mathematical").Page("Trig Table").Frame("Frame").WebElement("Lessons, Animations, Videos").FireEvent "onmouseover",45,8
Browser("S.O.S. Math - Mathematical").Page("Trig Table").WebTable("0").Check CheckPoint("0")
x = Browser("S.O.S. Math - Mathematical").Page("Trig Table").WebTable("0").GetCellData(2,4)
msgbox " value is." & x
Browser("S.O.S. Math – Mathematical").CloseAllTabs
Browser("S.O.S. Math - Mathematical").Page("S.O.S. Math - Mathematical").Frame("Frame").Check CheckPoint("Frame")
Browser("S.O.S. Math - Mathematical").Page("S.O.S. Math - Mathematical").Frame("Frame").WebElement("Class 1 to Class 12 Lessons,").FireEvent "onmouseover",718,13
Browser("S.O.S. Math - Mathematical").Page("S.O.S. Math - Mathematical").Link("A Trigonometric Table").Click 66,12
Browser("S.O.S. Math - Mathematical").Navigate "http://www.sosmath.com/tables/trigtable/trigtable.html"
Browser("S.O.S. Math - Mathematical").Page("Trig Table").Frame("Frame").Check CheckPoint("Frame_2")
Browser("S.O.S. Math - Mathematical").Page("Trig Table").Frame("Frame").Link("Class 1 to Class 12").FireEvent "onmouseover",42,1
Browser("S.O.S. Math - Mathematical").Page("Trig Table").Frame("Frame").WebElement("Lessons, Animations, Videos").FireEvent "onmouseover",45,8
Browser("S.O.S. Math - Mathematical").Page("Trig Table").WebTable("0").Check CheckPoint("0")
x = Browser("S.O.S. Math - Mathematical").Page("Trig Table").WebTable("0").GetCellData(2,4)
msgbox " value is." & x
Browser("S.O.S. Math – Mathematical").CloseAllTabs
Web link counter script
Dim Des_obj,link_col
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive").Check CheckPoint("editorial » Blog Archive_2")
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive").Link("Debt Consolidation").Click 48,5
Browser("editorial » Blog Archive_2").Navigate "http://editorial.co.in/debt-consolidation/debt-consolidation.php"
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive_2").Check CheckPoint("editorial » Blog Archive_3")
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive_2").Link("Debt Consolidation Calculator").Click 121,4
Browser("editorial » Blog Archive_2").Navigate "http://www.lendingtree.com/home-equity-loans/calculators/loan-consolidation-calculator"
Browser("editorial » Blog Archive_2").Navigate "http://www.lendingtree.com/home-equity-loans/calculators/loan-consolidation-calculator/"
Browser("editorial » Blog Archive_2").Back
Browser("editorial » Blog Archive_2").Navigate "http://editorial.co.in/debt-consolidation/debt-consolidation.php"
Browser("editorial » Blog Archive_2").Back
Browser("editorial » Blog Archive_2").Navigate "http://editorial.co.in/software/software-testing-life-cycle.php"
Set Des_obj = Description.Create
Des_obj("micclass").value = "Link"
Set link_col = Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive").ChildObjects(Des_obj)
msgbox link_col.count
Browser("editorial » Blog Archive_2").CloseAllTabs
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive").Check CheckPoint("editorial » Blog Archive_2")
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive").Link("Debt Consolidation").Click 48,5
Browser("editorial » Blog Archive_2").Navigate "http://editorial.co.in/debt-consolidation/debt-consolidation.php"
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive_2").Check CheckPoint("editorial » Blog Archive_3")
Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive_2").Link("Debt Consolidation Calculator").Click 121,4
Browser("editorial » Blog Archive_2").Navigate "http://www.lendingtree.com/home-equity-loans/calculators/loan-consolidation-calculator"
Browser("editorial » Blog Archive_2").Navigate "http://www.lendingtree.com/home-equity-loans/calculators/loan-consolidation-calculator/"
Browser("editorial » Blog Archive_2").Back
Browser("editorial » Blog Archive_2").Navigate "http://editorial.co.in/debt-consolidation/debt-consolidation.php"
Browser("editorial » Blog Archive_2").Back
Browser("editorial » Blog Archive_2").Navigate "http://editorial.co.in/software/software-testing-life-cycle.php"
Set Des_obj = Description.Create
Des_obj("micclass").value = "Link"
Set link_col = Browser("editorial » Blog Archive_2").Page("editorial » Blog Archive").ChildObjects(Des_obj)
msgbox link_col.count
Browser("editorial » Blog Archive_2").CloseAllTabs
Find Tooltips of the specific website
Dim descImage,listImages,attrAltText,attrSrcText
Browser("Browser_2").Navigate "http://www.medusind.com/"
Browser("US Healthcare Revenue").Page("US Healthcare Revenue").Image("Medusind Solutions - Enabling").Click 150,9
Browser("Browser_2").Navigate "http://www.medusind.com/index.asp"
set descImage = description.create
descImage("html tag").value = "IMG"
SET listImages = Browser("Webpage error").page("US Healthcare Revenue").childobjects(descImage)
For i=0 to listimages.count-1
attrAltText = ListImages(i).GetRoProperty("alt")
attrrcText = listImages(i).GetRopRoperty("src")
If attrAltText <> "" Then
Msgbox "Images src: " & attrSrcText & vbnewline & "Tooltip: " & attrAltText
End If
Next
Browser("Webpage error").CloseAllTabs
Browser("Browser_2").Navigate "http://www.medusind.com/"
Browser("US Healthcare Revenue").Page("US Healthcare Revenue").Image("Medusind Solutions - Enabling").Click 150,9
Browser("Browser_2").Navigate "http://www.medusind.com/index.asp"
set descImage = description.create
descImage("html tag").value = "IMG"
SET listImages = Browser("Webpage error").page("US Healthcare Revenue").childobjects(descImage)
For i=0 to listimages.count-1
attrAltText = ListImages(i).GetRoProperty("alt")
attrrcText = listImages(i).GetRopRoperty("src")
If attrAltText <> "" Then
Msgbox "Images src: " & attrSrcText & vbnewline & "Tooltip: " & attrAltText
End If
Next
Browser("Webpage error").CloseAllTabs
message window validation
If not dialog( "Login").Exist(2)Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\",""
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e2e616befbf25362991054e9261351ead9a"
Dialog("Login").WinButton("OK").Click
Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Help").Click
Dialog("Flight Reservations").Static("The password is 'MERCURY'").Check CheckPoint("The password is 'MERCURY'")
message = Dialog("text:= Login").dialog("text:= Flight Reservations").Static("window id:= 65535").GetROProperty("text")
Dialog("Flight Reservations").WinButton("OK").Click
If message = "The password is 'MERCURY'" Then
reporter.ReportEvent 0,"Res","Correct message" & message
else
reporter.ReportEvent 1,"Res","Incorrect message"
End If
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\",""
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e2e616befbf25362991054e9261351ead9a"
Dialog("Login").WinButton("OK").Click
Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Help").Click
Dialog("Flight Reservations").Static("The password is 'MERCURY'").Check CheckPoint("The password is 'MERCURY'")
message = Dialog("text:= Login").dialog("text:= Flight Reservations").Static("window id:= 65535").GetROProperty("text")
Dialog("Flight Reservations").WinButton("OK").Click
If message = "The password is 'MERCURY'" Then
reporter.ReportEvent 0,"Res","Correct message" & message
else
reporter.ReportEvent 1,"Res","Incorrect message"
End If
Check Checkbox using Descriptive programming
Option explicit
Dim qtp,flight_app,f,t,i,j,x,y
If not Window("text:= Flight Reservation:").Exist (2) = true Then
qtp = Environment("ProductDir")
Flight_app = "\samples\flight\app\flight4a.exe"
SystemUtil.Run qtp & Flight_app
Dialog("text:= Login").Activate
Dialog("text:= Login").WinEdit("attached text:= Agent Name:").Set "asdf"
Dialog("text:= Login").WinEdit("attached text:= Password:").SetSecure "4e2d605c46a3b5d32706b9ea1735d00e79319dd2"
Dialog("text:= Login").WinButton("text:= OK").Click
End If
Window("text:= Flight Reservation").Activate
Window("text:= Flight Reservation").Activex("Acx_name:= MaskEdBox","window id:=0").Type "121212"
f = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly From:").GetItemsCount
For i= 0 to f-1 step 1
Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").Select(i)
x =Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").GetROProperty("text")
t = Window("text:=Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetItemsCount
For J = 0 TO t-1 step 1
Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").Select(j)
y = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetROProperty("text")
If x <> y Then
Reporter.ReportEvent 0,"Res","Test passed"
else
Reporter.ReportEvent 1,"Res","Test Failed"
End If
Next
Next
Dim qtp,flight_app,f,t,i,j,x,y
If not Window("text:= Flight Reservation:").Exist (2) = true Then
qtp = Environment("ProductDir")
Flight_app = "\samples\flight\app\flight4a.exe"
SystemUtil.Run qtp & Flight_app
Dialog("text:= Login").Activate
Dialog("text:= Login").WinEdit("attached text:= Agent Name:").Set "asdf"
Dialog("text:= Login").WinEdit("attached text:= Password:").SetSecure "4e2d605c46a3b5d32706b9ea1735d00e79319dd2"
Dialog("text:= Login").WinButton("text:= OK").Click
End If
Window("text:= Flight Reservation").Activate
Window("text:= Flight Reservation").Activex("Acx_name:= MaskEdBox","window id:=0").Type "121212"
f = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly From:").GetItemsCount
For i= 0 to f-1 step 1
Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").Select(i)
x =Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").GetROProperty("text")
t = Window("text:=Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetItemsCount
For J = 0 TO t-1 step 1
Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").Select(j)
y = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetROProperty("text")
If x <> y Then
Reporter.ReportEvent 0,"Res","Test passed"
else
Reporter.ReportEvent 1,"Res","Test Failed"
End If
Next
Next
Getting dynamic text from the webpage by using text output value function
Step 1: Open google and type as site: motevich.blogspot.com QTP
Step 2: Click search button
Step 3: get a searched result
Step 4: see below google search bar we can view no of results displayed like 1000 or 2000
Step 5: now we can capture that no of values only
Step 6: now just change as test instead of QTP
Step 7: Click search button
Step 8: get a searched result
Step 9: now we can get someother result like 3000 or 4000
Step 10: Stop recording
Step 11: Go to active screen and select the value what we want to get and right click that
Step 12: just click text output value ,screen will open
Step 13: Make some changes in that window
Step 14: click ok
Step 15: again run the script
Browser("Google").Page("Google").WebEdit("q").Set "site: motevich.blogspot.com QTP"
Browser("Google").Page("Google").WebButton("Google Search").Click
Browser("Google").Page("site: motevich.blogspot.com").Sync
Browser("Google").Page("Google").Output CheckPoint("ResCount_2")
msgbox Datatable.Value("count")
Browser("Google").CloseAllTabs
Step 2: Click search button
Step 3: get a searched result
Step 4: see below google search bar we can view no of results displayed like 1000 or 2000
Step 5: now we can capture that no of values only
Step 6: now just change as test instead of QTP
Step 7: Click search button
Step 8: get a searched result
Step 9: now we can get someother result like 3000 or 4000
Step 10: Stop recording
Step 11: Go to active screen and select the value what we want to get and right click that
Step 12: just click text output value ,screen will open
Step 13: Make some changes in that window
Step 14: click ok
Step 15: again run the script
Browser("Google").Page("Google").WebEdit("q").Set "site: motevich.blogspot.com QTP"
Browser("Google").Page("Google").WebButton("Google Search").Click
Browser("Google").Page("site: motevich.blogspot.com").Sync
Browser("Google").Page("Google").Output CheckPoint("ResCount_2")
msgbox Datatable.Value("count")
Browser("Google").CloseAllTabs
Verify the Check point and if check point is true or false further process is handled using functional statement
Dim Str
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e2558dc476c11a2ea3597e2545811aef6477598"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").WinComboBox("Fly To:").Check CheckPoint("Fly To:_2")
Str = Window("Flight Reservation").WinComboBox("Fly To:").Check (CheckPoint("Fly To:"))
msgbox (Str)
If Str = true Then
process()
Else
exitaction()
End If
Private Function process()
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("OK").Click
exitaction()
End Function
Private Function exitaction()
Window("Flight Reservation").Close
End Function
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e2558dc476c11a2ea3597e2545811aef6477598"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").WinComboBox("Fly To:").Check CheckPoint("Fly To:_2")
Str = Window("Flight Reservation").WinComboBox("Fly To:").Check (CheckPoint("Fly To:"))
msgbox (Str)
If Str = true Then
process()
Else
exitaction()
End If
Private Function process()
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("OK").Click
exitaction()
End Function
Private Function exitaction()
Window("Flight Reservation").Close
End Function
Open Various Application using vb script
Dim wsh
Public Function Launch_App(arg1)
Set wsh=CreateObject("wscript.shell")
wsh.run arg1
Set wsh=nothing
End Function
Call Launch_App("Notepad.exe")
wait 1
Call Launch_App("cmd.exe")
wait 1
Call Launch_App("www.google.com")
wait 1
Call Launch_App("calc.exe")
Public Function Launch_App(arg1)
Set wsh=CreateObject("wscript.shell")
wsh.run arg1
Set wsh=nothing
End Function
Call Launch_App("Notepad.exe")
wait 1
Call Launch_App("cmd.exe")
wait 1
Call Launch_App("www.google.com")
wait 1
Call Launch_App("calc.exe")
Run Multiple QTP Test Script using command prompt and display results in command prompt itself
Dim APP //Declaration
Set APP = CreateObject("QuickTest.Application") //create Application object
App.Launch //Start Quicktestapplication
App.Visible = True //make QTP Application visible
Dim QTP_Tests(3) //Declaration
QTP_Tests(1) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\pagecheckpoint" //Set path
QTP_Tests(2) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\textcheckpoint" //Set path
QTP_Tests(3) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\Tooltip" //Set path
set res_obj = CreateObject("QuickTest.RunResultsOptions") //Create run result object
For i=1 to Ubound(QTP_Tests) //For loop running Multiple application
App.Open QTP_Tests(i),True
Set QTP_Test = App.Test
res_obj.ResultsLocation = Qtp_Tests(i) & "QTPResults"
Qtp_Test.Run res_obj,True
QTP_Test.close
Next
App.Quit //Quit the Application
Set res_obj = nothing //Release Result object
Set QTP_Test = nothing // Release the test object
Set App = nothing // Release the application object
Set APP = CreateObject("QuickTest.Application") //create Application object
App.Launch //Start Quicktestapplication
App.Visible = True //make QTP Application visible
Dim QTP_Tests(3) //Declaration
QTP_Tests(1) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\pagecheckpoint" //Set path
QTP_Tests(2) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\textcheckpoint" //Set path
QTP_Tests(3) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\Tooltip" //Set path
set res_obj = CreateObject("QuickTest.RunResultsOptions") //Create run result object
For i=1 to Ubound(QTP_Tests) //For loop running Multiple application
App.Open QTP_Tests(i),True
Set QTP_Test = App.Test
res_obj.ResultsLocation = Qtp_Tests(i) & "QTPResults"
Qtp_Test.Run res_obj,True
QTP_Test.close
Next
App.Quit //Quit the Application
Set res_obj = nothing //Release Result object
Set QTP_Test = nothing // Release the test object
Set App = nothing // Release the application object
Monday, August 29, 2011
Check Checkbox using Descriptive programming
Option explicit
Dim qtp,flight_app,f,t,i,j,x,y
If not Window("text:= Flight Reservation:").Exist (2) = true Then
qtp = Environment("ProductDir")
Flight_app = "\samples\flight\app\flight4a.exe"
SystemUtil.Run qtp & Flight_app
Dialog("text:= Login").Activate
Dialog("text:= Login").WinEdit("attached text:= Agent Name:").Set "asdf"
Dialog("text:= Login").WinEdit("attached text:= Password:").SetSecure "4e2d605c46a3b5d32706b9ea1735d00e79319dd2"
Dialog("text:= Login").WinButton("text:= OK").Click
End If
Window("text:= Flight Reservation").Activate
Window("text:= Flight Reservation").Activex("Acx_name:= MaskEdBox","window id:=0").Type "121212"
f = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly From:").GetItemsCount
For i= 0 to f-1 step 1
Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").Select(i)
x =Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").GetROProperty("text")
t = Window("text:=Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetItemsCount
For J = 0 TO t-1 step 1
Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").Select(j)
y = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetROProperty("text")
If x <> y Then
Reporter.ReportEvent 0,"Res","Test passed"
else
Reporter.ReportEvent 1,"Res","Test Failed"
End If
Next
Next
Count Buttons of Flight reservation window
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\",""
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e1ebb0beb016ff0acd0c8d19e774cb573"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20262 DEN 10:12 AM LON 05:23 PM AA $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "ranab"
Window("Flight Reservation").WinButton("Insert Order").Click
Call Count_Buttons()
Window("Flight Reservation").Close
write function in separate function window and add resource while running any script:
Function Count_Buttons()
Dim oButton,Buttons,ToButtons,i
Set oButton = Description.Create
oButton("Class Name").value = "WinButton"
Set Buttons = Window("text:= Flight Reservation").ChildObjects(oButton)
ToButtons = Buttons.count
msgbox ToButtons
End Function
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e1ebb0beb016ff0acd0c8d19e774cb573"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20262 DEN 10:12 AM LON 05:23 PM AA $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "ranab"
Window("Flight Reservation").WinButton("Insert Order").Click
Call Count_Buttons()
Window("Flight Reservation").Close
write function in separate function window and add resource while running any script:
Function Count_Buttons()
Dim oButton,Buttons,ToButtons,i
Set oButton = Description.Create
oButton("Class Name").value = "WinButton"
Set Buttons = Window("text:= Flight Reservation").ChildObjects(oButton)
ToButtons = Buttons.count
msgbox ToButtons
End Function
Count Buttons of Flight reservation window
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\",""
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e1ebb0beb016ff0a573"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20262 DEN 10:12 AM LON 05:23 PM AA $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "ranab"
Window("Flight Reservation").WinButton("Insert Order").Click
Call Count_Buttons()
Window("Flight Reservation").Close
write function in separate function window and add resource while running any script:
Function Count_Buttons()
Dim oButton,Buttons,ToButtons,i
Set oButton = Description.Create
oButton("Class Name").value = "WinButton"
Set Buttons = Window("text:= Flight Reservation").ChildObjects(oButton)
ToButtons = Buttons.count
msgbox ToButtons
End Function
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e1ebb0beb016ff0a573"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20262 DEN 10:12 AM LON 05:23 PM AA $112.20"
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "ranab"
Window("Flight Reservation").WinButton("Insert Order").Click
Call Count_Buttons()
Window("Flight Reservation").Close
write function in separate function window and add resource while running any script:
Function Count_Buttons()
Dim oButton,Buttons,ToButtons,i
Set oButton = Description.Create
oButton("Class Name").value = "WinButton"
Set Buttons = Window("text:= Flight Reservation").ChildObjects(oButton)
ToButtons = Buttons.count
msgbox ToButtons
End Function
Friday, August 19, 2011
QTP Scripts
Script to finding out Broken link:
'Start of Code
Set a=Browser().Page().Link()
Dim URL,httprot
URL=a.GetROProperty("href")
Set httprot = CreateObject("MSXML2.XmlHttp")
httprot.open "GET",URL,FALSE
On Error Resume Next
httprot.send()
Print httprot.Status
If httprot.Status<>200 Then
msgbox "fail"
Else
msgbox "pass"
End If
Set httprot = Nothing
'End Of Code
---------------------------------------------------------
Get names of all open Browsers:
Set bDesc = Description.Create()
bDesc(“application version”).Value = “internet explorer 6″
Set bColl = DeskTop.ChildObjects(bDesc)
Cnt = bColl.Count
MsgBox “There are total:”&Cnt&”browsers opened”
For i = 0 To (Cnt -1)
MsgBox “Browser: “&i&” has title: “& bColl(i).GetROProperty(“title”)
Next ‘ i
Set bColl = Nothing
Set bDesc = Nothing
------------------------------------------------------------
QTP Scripts to captures a text of the Tooltip:
' Place mouse cursor over the link
Browser("Yahoo!").Page("Yahoo!").WebElement("text:=My Yahoo!").FireEvent "onmouseover"
wait 1
' Grab tooltip
ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")
Capturing Tooltip of the images:
Now, I'm going to show how to show how to capture tool tips of images located on a Web page.Actually, the solution is simple.
To capture a tool tip of an image, we can get value of "alt" Run-time Object property with GetROProperty("alt") function:
Browser("brw").Page("pg").GetROProperty("alt")
Let's verify this code in practice. For example, let's check tooltips from Wikipedia Main page
'Start of Code
Set a=Browser().Page().Link()
Dim URL,httprot
URL=a.GetROProperty("href")
Set httprot = CreateObject("MSXML2.XmlHttp")
httprot.open "GET",URL,FALSE
On Error Resume Next
httprot.send()
Print httprot.Status
If httprot.Status<>200 Then
msgbox "fail"
Else
msgbox "pass"
End If
Set httprot = Nothing
'End Of Code
---------------------------------------------------------
Get names of all open Browsers:
Set bDesc = Description.Create()
bDesc(“application version”).Value = “internet explorer 6″
Set bColl = DeskTop.ChildObjects(bDesc)
Cnt = bColl.Count
MsgBox “There are total:”&Cnt&”browsers opened”
For i = 0 To (Cnt -1)
MsgBox “Browser: “&i&” has title: “& bColl(i).GetROProperty(“title”)
Next ‘ i
Set bColl = Nothing
Set bDesc = Nothing
------------------------------------------------------------
QTP Scripts to captures a text of the Tooltip:
' Place mouse cursor over the link
Browser("Yahoo!").Page("Yahoo!").WebElement("text:=My Yahoo!").FireEvent "onmouseover"
wait 1
' Grab tooltip
ToolTip = Window("nativeclass:=tooltips_class32").GetROProperty("text")
Capturing Tooltip of the images:
Now, I'm going to show how to show how to capture tool tips of images located on a Web page.Actually, the solution is simple.
To capture a tool tip of an image, we can get value of "alt" Run-time Object property with GetROProperty("alt") function:
Browser("brw").Page("pg").GetROProperty("alt")
Let's verify this code in practice. For example, let's check tooltips from Wikipedia Main page
Monday, April 4, 2011
How to identify broken links in QTP
Broken Links also sometimes called as dead links are those links on the web which are permanently unavailable. Commonly found, 404 error is one example of such link. Now the question is how can we identify broken links with the help of QTP during the run session?
There can be two ways to do this:
1.Using Automatic Page checkpoint.
2.By manually creating a Page checkpoint.
Using Automatic Page checkpoint: Go to Tools > Options > Web > Advanced and check the two boxes labeled “Create a checkpoint for each page while recording” and “Broken Links”

Now every time you record a new page, QTP will automatically include a checkpoint for broken links.
By manually creating a Page checkpoint: QTP does not provide a direct menu option to incorporate a page checkpoint. You need to take the help of standard checkpoint. Start recording session > Insert > Checkpoint > Standard Checkpoint (OR press F12). Place and click the hand pointer anywhere on your web page. Select Page (As shown in picture below) and Click OK.

You will get the following screen:

Check “Broken Link” checkbox down below and click OK.
Now, how will you verify page checkpoint and hence broken links?
Run the above script. Go To Test Results > Your Check Point. Check the status of all links under “Broken Links Result”
If you want to verify links pointing only to the current host check the box titled “Broken Links- check only links to current host” under Tools > Options > Web. Similarly If you want to verify links pointing to other hosts as well, uncheck it.
There can be two ways to do this:
1.Using Automatic Page checkpoint.
2.By manually creating a Page checkpoint.
Using Automatic Page checkpoint: Go to Tools > Options > Web > Advanced and check the two boxes labeled “Create a checkpoint for each page while recording” and “Broken Links”

Now every time you record a new page, QTP will automatically include a checkpoint for broken links.
By manually creating a Page checkpoint: QTP does not provide a direct menu option to incorporate a page checkpoint. You need to take the help of standard checkpoint. Start recording session > Insert > Checkpoint > Standard Checkpoint (OR press F12). Place and click the hand pointer anywhere on your web page. Select Page (As shown in picture below) and Click OK.

You will get the following screen:

Check “Broken Link” checkbox down below and click OK.
Now, how will you verify page checkpoint and hence broken links?
Run the above script. Go To Test Results > Your Check Point. Check the status of all links under “Broken Links Result”
If you want to verify links pointing only to the current host check the box titled “Broken Links- check only links to current host” under Tools > Options > Web. Similarly If you want to verify links pointing to other hosts as well, uncheck it.

How to get Text of statusbar from the QTP
When you work in QTP with Web applications, it is sometimes necessary to get a text of browser's status bar.
Let's see for example the following browser:

There are two ways:
1.Object.StatusText property of Browser object
2.GetROProperty("text") method of WinStatusBar object
1.Getting text of Status Bar using Object.StatusText property of Browser object
To access text of Status Bar, we use Browser's Object object and its StatusText property.
Browser("bname").Object is a reference to the Internet Explorer's DOM object. To be more precise, it's a reference to the Internet Explorer's IWebBrowser2 interface.
Using Browser("bname").Object, you can access different methods and properties of IE, for example:
#
Statement
Meaning
1
Browser("bname").Object.GoBack
Navigates backward one item in the history list
2
Browser("bname").Object.LocationURL
Gets the URL of the page that is currently displayed
3
Browser("bname").Object.StatusText
Sets or gets the text in the status bar for the object
4
Browser("bname").Object.ToolBar
Sets or gets whether toolbars for the object are visible
So, our code is simpe enough:
sText = Browser("QTP - How to get Status").Object.StatusText
MsgBox sText
And its result is:

Note: Since we use Internet Explorer's IWebBrowser2 interface, we can use this solution win IE only. It doesn't work with FireFox. The next solution will be compatibe with both IE and FF.
1.Getting text of Status Bar using GetROProperty("text") method of WinStatusBar object
Status bar is a part of browser's window. There is a special class to handle it from QTP - WinStatusBar. We can get text of WinStatusBar using GetROProperty("text") method.
So, I add Status Bar to QTP's Object Repository (OR):

The final script is:
sText = Browser("QTP - How to get Status").WinStatusBar("msctls_statusbar32").GetROProperty("text")
MsgBox sText
And its result is:

Note: This solution works correctly both for IE and FF, but it requires additional operations with Object Repository.
Let's see for example the following browser:

There are two ways:
1.Object.StatusText property of Browser object
2.GetROProperty("text") method of WinStatusBar object
1.Getting text of Status Bar using Object.StatusText property of Browser object
To access text of Status Bar, we use Browser's Object object and its StatusText property.
Browser("bname").Object is a reference to the Internet Explorer's DOM object. To be more precise, it's a reference to the Internet Explorer's IWebBrowser2 interface.
Using Browser("bname").Object, you can access different methods and properties of IE, for example:
#
Statement
Meaning
1
Browser("bname").Object.GoBack
Navigates backward one item in the history list
2
Browser("bname").Object.LocationURL
Gets the URL of the page that is currently displayed
3
Browser("bname").Object.StatusText
Sets or gets the text in the status bar for the object
4
Browser("bname").Object.ToolBar
Sets or gets whether toolbars for the object are visible
So, our code is simpe enough:
sText = Browser("QTP - How to get Status").Object.StatusText
MsgBox sText
And its result is:

Note: Since we use Internet Explorer's IWebBrowser2 interface, we can use this solution win IE only. It doesn't work with FireFox. The next solution will be compatibe with both IE and FF.
1.Getting text of Status Bar using GetROProperty("text") method of WinStatusBar object
Status bar is a part of browser's window. There is a special class to handle it from QTP - WinStatusBar. We can get text of WinStatusBar using GetROProperty("text") method.
So, I add Status Bar to QTP's Object Repository (OR):

The final script is:
sText = Browser("QTP - How to get Status").WinStatusBar("msctls_statusbar32").GetROProperty("text")
MsgBox sText
And its result is:

Note: This solution works correctly both for IE and FF, but it requires additional operations with Object Repository.
Tuesday, March 29, 2011
Ways to launch our Application
Four different ways to launch your application are mentioned below:
1) SystemUtil.Run
SystemUtil.Run ( FileName, Parameters, Path, Operation )
FileName - The name of the file you want to run.
Parameters - If the specified FileName is an executable file, use the Parameters argument to specify any parameters to be passed to the application.
Path - The default directory of the application or file.
Operation - The action to be performed. If this argument is blank (""), the open operation is performed.
The following operations can be specified for the operation argument of the SystemUtil.Run method:
open - Opens the file specified by the FileName parameter. The file can be an executable file, a document file, or a folder. Non-executable files are open in the associated application.
edit - Launches an editor and opens the document for editing. If the FileName argument does not specify an editable document file, the statement fails.
explore - Explores the folder specified by the FileName argument.
find - Initiates a search starting from the specified folder path.
print - Prints the document file specified by the FileName argument. If the specified file is not a printable document file, the statement fails.
Example:SystemUtil.Run "D:\My Music\Breathe.mp3","","D:\My Music\Details","open"
2) InvokeApplication
This command is now mainly used for the backward compatability ie to use with the lower versions(below QTP 6.0) of QTP.
InvokeApplication("Full URL as Parameter")
Example:InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.yahoo.com"
3) VBscript to invoke application
1. Create a "WScript.shell" object.
2. Use the "run" object to launch the application. If the path to your executable contains spaces, use Chr(34) to ensure the path is contained within double quotes.
3. When done, set the shell object to nothing to release it.
Example:
Dim oShellSet oShell = CreateObject ("Wscript.shell")'
Example 1 - run a batch file:oShell.run "F:\jdk1.3.1\demo\jfc\SwingSet2.bat"'
Example 2 - run a Java jar file:oShell.run "java -jar F:\jdk1.3.1\demo\jfc\SwingSet2\SwingSet2.jar"'
Example 3 - launch Internet Explorer:oShell.Run Chr(34) & "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & Chr(34)Set oShell = Nothing
4) Trivial but useful method
If nothing works out you might try this
You can use the Start -> Run dialog of Windows.
1. Add the Windows Start button to the Object Repository using the "Add Objects" button in Object Repository dialog.
2. Open the Run dialog (Start -> Run), and learn the "Open" edit field and the "OK" button into the Object Repository.
3. Switch to the Expert View, and manually add the lines to open the Run dialog.
Example:Window("Window").WinButton("Button").ClickWindow("Window").Type("R")
4. Manually enter the lines to enter the information to launch the application, and click the "OK" button of the Run dialog.
Example:
Dialog("Run").WinEdit("Open:").Type "c:\WINNT\system32\notepad.exe"
Dialog("Run").WinButton("OK").Click
1) SystemUtil.Run
SystemUtil.Run ( FileName, Parameters, Path, Operation )
FileName - The name of the file you want to run.
Parameters - If the specified FileName is an executable file, use the Parameters argument to specify any parameters to be passed to the application.
Path - The default directory of the application or file.
Operation - The action to be performed. If this argument is blank (""), the open operation is performed.
The following operations can be specified for the operation argument of the SystemUtil.Run method:
open - Opens the file specified by the FileName parameter. The file can be an executable file, a document file, or a folder. Non-executable files are open in the associated application.
edit - Launches an editor and opens the document for editing. If the FileName argument does not specify an editable document file, the statement fails.
explore - Explores the folder specified by the FileName argument.
find - Initiates a search starting from the specified folder path.
print - Prints the document file specified by the FileName argument. If the specified file is not a printable document file, the statement fails.
Example:SystemUtil.Run "D:\My Music\Breathe.mp3","","D:\My Music\Details","open"
2) InvokeApplication
This command is now mainly used for the backward compatability ie to use with the lower versions(below QTP 6.0) of QTP.
InvokeApplication("Full URL as Parameter")
Example:InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.yahoo.com"
3) VBscript to invoke application
1. Create a "WScript.shell" object.
2. Use the "run" object to launch the application. If the path to your executable contains spaces, use Chr(34) to ensure the path is contained within double quotes.
3. When done, set the shell object to nothing to release it.
Example:
Dim oShellSet oShell = CreateObject ("Wscript.shell")'
Example 1 - run a batch file:oShell.run "F:\jdk1.3.1\demo\jfc\SwingSet2.bat"'
Example 2 - run a Java jar file:oShell.run "java -jar F:\jdk1.3.1\demo\jfc\SwingSet2\SwingSet2.jar"'
Example 3 - launch Internet Explorer:oShell.Run Chr(34) & "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & Chr(34)Set oShell = Nothing
4) Trivial but useful method
If nothing works out you might try this
You can use the Start -> Run dialog of Windows.
1. Add the Windows Start button to the Object Repository using the "Add Objects" button in Object Repository dialog.
2. Open the Run dialog (Start -> Run), and learn the "Open" edit field and the "OK" button into the Object Repository.
3. Switch to the Expert View, and manually add the lines to open the Run dialog.
Example:Window("Window").WinButton("Button").ClickWindow("Window").Type("R")
4. Manually enter the lines to enter the information to launch the application, and click the "OK" button of the Run dialog.
Example:
Dialog("Run").WinEdit("Open:").Type "c:\WINNT\system32\notepad.exe"
Dialog("Run").WinButton("OK").Click
Recovery Scenarios
Recovery Scenario Manager:
To recover from unexpected events and errors that are occurred in the test environment during run session, we can use Recovery Scenario Manager. For good recovery, error must be known the occurrence is unknown.
There are (4) Types of events such as:
(i) Application Crash
An open application fails during Test Run.
Navigation:
Resources Menu -> Recovery Scenario Manager-> Click New-> Click Next ->
Select Application Crash as Trigger event->Next ->Select selected executable
application->Next ->Select Recovery Operation [Keyboard, Mouse Operation,
Close Application Process, function Call, Restart, Microsoft Windows] ->Next ->If
you want to check Add another operation else uncheck->Next ->Next ->Enter
Scenario Name ->Next->Select Option ->Finish ->Close ->Save the scenario in
specified location with “.qrs”
(qrs stands for QuickTest Recovery Scenario.)
(ii) Popup Window.
To handle unwanted popups.
Navigation:
Resources Menu ->Recovery Scenario Manager ->New ->Next ->Select “Popup
Window” as Trigger event ->Next ->Click on Hand Icon ->Show unwanted
window with Hand icon ->Next ->Next ->Select function call as Recovery
Operation ->Next [Open Notepad ->Save empty file with .vbs extension] ->Browse
the .vbs fie path ->Next ->Uncheck Add another Recovery Operation ->Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] ->Next ->Enter Scenario Name ->Next ->Select Option ->
Finish ->Save the scenario with “.qrs” ->Record required Recovery Operation [Click
ok, Click Cancel] take the script into function ->Save the library file ->Click Run
(iii) Test Run Error.
A step in your test does not run successfully then Test Run Error
can be raised.
Navigation :
Resources Menu ->Recovery Scenario Manager ->New ->Next ->Select “Testrunerror
Window” as Trigger event ->Next ->select any error o ->Next ->Next ->Select function call as Recovery
Operation ->Next [Open Notepad ->Save empty file with .vbs extension] ->Browse
the .vbs fie path ->Next ->Uncheck Add another Recovery Operation ->Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] ��Next ��Enter Scenario Name ��Next ��Select Option ��
Finish ��Save the scenario with “.qrs” ��Record required Recovery Operation [Click
ok, Click Cancel] take the script into function ��Save the library file ��Click Run
(iv) Object State.
The property values of an object in your application match
specified values. You can specify property values for each object in the
hierarchy.
Navigation:
Resources Menu -> Recovery Scenario Manager -> New -> Next -> Select “Object state
Window” as Trigger event -> Next -> Click on Hand Icon -> Show object with hand icon
-> Next -> Next->select object property with value (enabled ,false)->click next -> Select function call as Recovery
Operation -> Next [Open Notepad -> Save empty file with .vbs extension] -> Browse
the .vbs fie path -> Next -> Uncheck Add another Recovery Operation -> Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] -> Next-> Enter Scenario Name -> Next -> Select Option ->
Finish -> Save the scenario with “.qrs” -> Record required Recovery Operation [Click
ok, Click Cancel] take the script into function -> Save the library file -> Click Run
While creating Recovery Scenario for Pop-up window..In 'Recovery operation' we have to call a function. Can u tell me that function?
1. Go to TOOLS -> Recovery scenario manager.
2. Select the trigger event that caused the error(it may be a pop up window).
3. Identify the name of the window with the help of POINTING HAND.
4. Choose the operation type : KEYBOARD OR MOUSE OPERATION.
5. Select the action with the help of POINTING HAND.(e.g.Click on OK button to close the window.)
6. If you want to add another action then keep "Add another
recovery scenario" check box selected else de select it.
7. In the "Post recovery test run option" select "Proceed to next test iteration"
8. Give scenario name & description & click on finish button.
9. Save the scenario.
10. Go to TEST->SETTINGS->SCENARIO TAB....and add the saved scenario.
11. Click on APPLY & OK button......now your test run smoothly.
see... generally we can handle those pop up window exeptions
by writing If then statement and using exist method.
for example...
If window("skdhja").dialog("text:=fahda").exist then
window("skdhja").dialog("text:=fahda").winbutton("text:=OK(or)Cancel").click
window("akdhja").close
else
If you select “Function call" option we have to select the
file containing our library functions.
then we will have two radio buttons
1.Select function
2.Define new function
if we select the 'select function' radio button then we have to use the following syntax
Function (Object)
‘ recovery information and code goes here
End Function
Example:
‘ Close the About Notepad window.
Function AboutWindow(Object)
Object.Highlight
Object.Close
End Function
if we choose 'Define new function' then Create a new
function by specifying a unique name for it, and defining
the function in the Function Name box according to the
displayed function prototype. The new function is added to
the library file you selected.
To recover from unexpected events and errors that are occurred in the test environment during run session, we can use Recovery Scenario Manager. For good recovery, error must be known the occurrence is unknown.
There are (4) Types of events such as:
(i) Application Crash
An open application fails during Test Run.
Navigation:
Resources Menu -> Recovery Scenario Manager-> Click New-> Click Next ->
Select Application Crash as Trigger event->Next ->Select selected executable
application->Next ->Select Recovery Operation [Keyboard, Mouse Operation,
Close Application Process, function Call, Restart, Microsoft Windows] ->Next ->If
you want to check Add another operation else uncheck->Next ->Next ->Enter
Scenario Name ->Next->Select Option ->Finish ->Close ->Save the scenario in
specified location with “.qrs”
(qrs stands for QuickTest Recovery Scenario.)
(ii) Popup Window.
To handle unwanted popups.
Navigation:
Resources Menu ->Recovery Scenario Manager ->New ->Next ->Select “Popup
Window” as Trigger event ->Next ->Click on Hand Icon ->Show unwanted
window with Hand icon ->Next ->Next ->Select function call as Recovery
Operation ->Next [Open Notepad ->Save empty file with .vbs extension] ->Browse
the .vbs fie path ->Next ->Uncheck Add another Recovery Operation ->Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] ->Next ->Enter Scenario Name ->Next ->Select Option ->
Finish ->Save the scenario with “.qrs” ->Record required Recovery Operation [Click
ok, Click Cancel] take the script into function ->Save the library file ->Click Run
(iii) Test Run Error.
A step in your test does not run successfully then Test Run Error
can be raised.
Navigation :
Resources Menu ->Recovery Scenario Manager ->New ->Next ->Select “Testrunerror
Window” as Trigger event ->Next ->select any error o ->Next ->Next ->Select function call as Recovery
Operation ->Next [Open Notepad ->Save empty file with .vbs extension] ->Browse
the .vbs fie path ->Next ->Uncheck Add another Recovery Operation ->Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] ��Next ��Enter Scenario Name ��Next ��Select Option ��
Finish ��Save the scenario with “.qrs” ��Record required Recovery Operation [Click
ok, Click Cancel] take the script into function ��Save the library file ��Click Run
(iv) Object State.
The property values of an object in your application match
specified values. You can specify property values for each object in the
hierarchy.
Navigation:
Resources Menu -> Recovery Scenario Manager -> New -> Next -> Select “Object state
Window” as Trigger event -> Next -> Click on Hand Icon -> Show object with hand icon
-> Next -> Next->select object property with value (enabled ,false)->click next -> Select function call as Recovery
Operation -> Next [Open Notepad -> Save empty file with .vbs extension] -> Browse
the .vbs fie path -> Next -> Uncheck Add another Recovery Operation -> Next ->
Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test
run, Stop the Test Run] -> Next-> Enter Scenario Name -> Next -> Select Option ->
Finish -> Save the scenario with “.qrs” -> Record required Recovery Operation [Click
ok, Click Cancel] take the script into function -> Save the library file -> Click Run
While creating Recovery Scenario for Pop-up window..In 'Recovery operation' we have to call a function. Can u tell me that function?
1. Go to TOOLS -> Recovery scenario manager.
2. Select the trigger event that caused the error(it may be a pop up window).
3. Identify the name of the window with the help of POINTING HAND.
4. Choose the operation type : KEYBOARD OR MOUSE OPERATION.
5. Select the action with the help of POINTING HAND.(e.g.Click on OK button to close the window.)
6. If you want to add another action then keep "Add another
recovery scenario" check box selected else de select it.
7. In the "Post recovery test run option" select "Proceed to next test iteration"
8. Give scenario name & description & click on finish button.
9. Save the scenario.
10. Go to TEST->SETTINGS->SCENARIO TAB....and add the saved scenario.
11. Click on APPLY & OK button......now your test run smoothly.
see... generally we can handle those pop up window exeptions
by writing If then statement and using exist method.
for example...
If window("skdhja").dialog("text:=fahda").exist then
window("skdhja").dialog("text:=fahda").winbutton("text:=OK(or)Cancel").click
window("akdhja").close
else
file containing our library functions.
then we will have two radio buttons
1.Select function
2.Define new function
if we select the 'select function' radio button then we have to use the following syntax
Function (Object)
‘ recovery information and code goes here
End Function
Example:
‘ Close the About Notepad window.
Function AboutWindow(Object)
Object.Highlight
Object.Close
End Function
if we choose 'Define new function' then Create a new
function by specifying a unique name for it, and defining
the function in the Function Name box according to the
displayed function prototype. The new function is added to
the library file you selected.
Friday, March 25, 2011
Script to verify the items exists in dropdown box
Public Function fnVerifyDropDownItems(objDropdown, strItemsToSearch)
Dim intItemsCount, intCounter, strItem, intItems, blnItemPresent
Dim arrItemsToSearch
fnVerifyDropDownItems=True
If (objDropdown.Exist = False) Then
reporter.report micFail,"The Dropdown box '" & objDropdown.GetROProperty("name") & "' should Exist", "The Dropdown Box does not exist", "FAIL")
fnVerifyDropDownItems=False
Exit Function
End If
'''''''' Get count of items in dropdown''''''''''''''''''
intItemsCount = objDropdown.GetTOProperty("items count")
''''''''Split the list items list based on comma(,)''''''
arrItemsToSearch = Split(strItemsToSearch, ",")
For intItems=0 to UBound(arrItemsToSearch)
blnItemPresent = False
''''''''''''Loop through all items''''''''''''''
For intCounter=1 to intItemsCount
strItem = ""
'''''''''' Get an item''''''''''''''''''
strItem = objDropdown.GetItem(intCounter)
'''''''''''''''If the search item is present'''''''''''''''''''''''
If (StrComp(Trim(strItem), Trim(arrItemsToSearch(intItems)), 1) = 0) Then
blnItemPresent = True
reporter.report micPass "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item exists in the dropdown box", "PASS")
Exit For
End If
Next
If (Not blnItemPresent) Then
reporter.report micFail , "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item does not exist in the dropdown box", "WARNING")
fnVerifyDropDownItems = False
End If
Next
End Function
Dim intItemsCount, intCounter, strItem, intItems, blnItemPresent
Dim arrItemsToSearch
fnVerifyDropDownItems=True
If (objDropdown.Exist = False) Then
reporter.report micFail,"The Dropdown box '" & objDropdown.GetROProperty("name") & "' should Exist", "The Dropdown Box does not exist", "FAIL")
fnVerifyDropDownItems=False
Exit Function
End If
'''''''' Get count of items in dropdown''''''''''''''''''
intItemsCount = objDropdown.GetTOProperty("items count")
''''''''Split the list items list based on comma(,)''''''
arrItemsToSearch = Split(strItemsToSearch, ",")
For intItems=0 to UBound(arrItemsToSearch)
blnItemPresent = False
''''''''''''Loop through all items''''''''''''''
For intCounter=1 to intItemsCount
strItem = ""
'''''''''' Get an item''''''''''''''''''
strItem = objDropdown.GetItem(intCounter)
'''''''''''''''If the search item is present'''''''''''''''''''''''
If (StrComp(Trim(strItem), Trim(arrItemsToSearch(intItems)), 1) = 0) Then
blnItemPresent = True
reporter.report micPass "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item exists in the dropdown box", "PASS")
Exit For
End If
Next
If (Not blnItemPresent) Then
reporter.report micFail , "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item does not exist in the dropdown box", "WARNING")
fnVerifyDropDownItems = False
End If
Next
End Function
Subscribe to:
Posts (Atom)