Posts: 4
Threads: 1
Joined: Aug 2009
Reputation:
0
08-13-2009, 09:03 PM
Hello Friends,
I tried to record the Windows Mercury Flight application, by
1. logging in
2. reserving a flight
3. selecting the default (first) option of the flight selection dialog winlist
4. inserted order
5. close application
Next, I parameterise the values for FlyFrom and FlyTo in Global Sheet
This works fine, while replay
But when I try to select a flight(point 3 above), say the 2nd or 3rd rows in the list of the flights, because I have parameterised the flight details, the test fails for the 2nd iteration.
Pls let me know wht changes I need to make this work.
thanks,
Sumithra
Posts: 41
Threads: 11
Joined: Aug 2009
Reputation:
0
08-13-2009, 11:53 PM
Hi Sumitra,
As you parameterized the test, when you are running 2nd row in the sheet, FlyFrom & FlyTo city values changes, Thus, the flights displayed are totally different from the flights you recorded.
Here is the Solution.
Select Index for the flight
Browser("").Page("").WinList("..").Select(1)
you can change the index.
Thanks
Ramesh
Posts: 4
Threads: 1
Joined: Aug 2009
Reputation:
0
08-14-2009, 02:42 AM
Thanks a lot Ramesh!!!. I wanted to know this for a long time.
One more question:
I parameterised that Index with a random number. So it will select the flight at random. This executes fine.
But I have a doubt here.
If I choose a random number between 1 and 10, and if the flight selection options have only 2, assume if the random number chosen is 3 or 4, the test will fail, because QTP will not be able to identify an object. Am i right? But I tried this, and the script passed. It took a random value of 4, 6, 5.
thanks again,
sumithra
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
08-14-2009, 12:24 PM
Get the collection of the items in the winlist. Spy on the winlist and see what are the TO properties which return the "Items Count". If you get that then you can use it this way,
a = RandomNumber(0, ItemsCount)
You should get a value which is within the total number of flights avaliable.
Wasnt this what you were looking for ?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
08-14-2009, 07:38 PM
Ahaa...Brilliant !!!
Well you did search with most of the keywords, but if you searched with Report or reported you would have found the answer. Well as a token of appreciation for valuing research here is the answer,
Reporter.reportevent micpass, "Test Passed", "Whatever text you want to write"&variablename
Read about Reporter.Reportevent to know more.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 4
Threads: 1
Joined: Aug 2009
Reputation:
0
08-14-2009, 07:50 PM
Hi Basanth,
Yeah, I know about the Reporter.ReportEvent. This Reporter object displays the value in the Results Window.
But I want to know the result in the QTP screen itself before seeing the results window - that is why i tried using print, msgbox, debug viewer to see the value of the flight selected randomly.
Thanks for the quick replies,
Sumithra
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
08-14-2009, 07:54 PM
Msgbox varname should help. Arent you able to see it ?
Try this,
Code:
itemCount = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("items count")
msgbox itemCount
a = RandomNumber(0, itemCount)
msgbox a
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.