Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cascading heirarchy drop down list timing problem
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hello,

I have a script that uses descriptive programming running against a web application. I am running into a problem with a set of drop down lists which are AJAX enabled. The load time of the lists often varies, and Qtp seems to be running too fast in some cases.

When a user selects an option from a drop down, a splash screen fills the page until the new set within the control has loaded. Choosing one of the options in a DDL determines the list in the box below it.

For example:
DDL 1: Options for Country. User Chooses "USA"
DDL 2: Loads in states or provinces within the USA, based on the previous selection. User Chooses "Alabama"
DDL 3: Loads all Cities from Alabama.... etc.

QTP seems to be trying to access the drop down before it finishes loading in the selections.

I have tried using Exists, WaitProperty, and Wait statements. The exists only verifies that the page loaded the drop down list, not the content of the list. WaitProperty seems only to be suited on checking if a selection has been made correctly. I have also tried searching the list to make sure that the entry i wish to select is in the "all items" property, but I cannot be sure that this check is run when the list has loaded. The only one of these that seems to be working as needed are the Wait statements. However, if the set takes too long to load, and my wait statement is too short, qtp will attempt to select an option from an empty list before it is loaded, and in the end, no option will be chosen at all.

The load time is fairly unpredictable at times, and since this action of choosing a drop down set is repeated hundreds (maybe thousands) of times within a single run of this script alone, I want to make sure it can run as quickly as possible, without making a wrong selection.

Here is the code I currently have in place:
Code:
Dim dpBrowser
dpBrowser = "micclass:=Browser"
Dim dpPage
dpPage = "micclass:=Page"

country = Trim(DataTable("country", dtLocalSheet))
state_province = Trim(DataTable("state_province", dtLocalSheet))
city = Trim(DataTable("city", dtLocalSheet))

<for loop here>
If country <> "" AND state_province <> "" AND city <> "" Then
    If Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").Exist(10) AND Instr(1, Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").getROProperty("all items"), country) <> 0 Then
        Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").Select country
        Wait(2)
    End If
    If Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlState_Province.*").Exist(10) AND Instr(1, Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlState_Province.*").getROProperty("all items"), state_province) <> 0 Then
        Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlState_Province.*").Select state_province
        Wait (2)
    End If
    If Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlcity.*").Exist(10) AND Instr(1, Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlcity.*").getROProperty("all items"), city) <> 0 Then
        Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlcity.*").Select city
        Wait (2)
    End If
End If
<some other code>
<save entry>
<end for loop>

Is a way to solve this problem, other than increasing the wait time?

Thank you,

Incite1321
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
You may also check for object.readystate property.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
How about a loop that constaintly checks for records in the dropdown to exists, waits if rowcount = 0

something like:
Code:
dim r
r=0
While r = 0
wait(5)
r = Browser("Browser").Page("Page").WebList("idType").GetROProperty("items count")
Wend

Might work....

PS: Properly formatted this time. I had to repost because I did not have rights to edit or delete my previous post.
Reply
#4
Solved: 11 Years, 4 Months, 3 Weeks ago
I have done that for you. Thanks jsknight1969.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#5
Solved: 11 Years, 4 Months, 3 Weeks ago
Thank you both for your generous help. With some fiddling around, I was able to find a solution.

I tried your solution first, Ankur. However, the readystate for the drop down lists was always set to "complete". I do not quite know why, since I did not write the code for the web app page.

I went on to try jsknight1969's solution, and after a while, I was able to make it work.

Here is the code, modified from the example I gave above:
Code:
Dim dpBrowser
dpBrowser = "micclass:=Browser"
Dim dpPage
dpPage = "micclass:=Page"

country = Trim(DataTable("country", dtLocalSheet))
state_province = Trim(DataTable("state_province", dtLocalSheet))
city = Trim(DataTable("city", dtLocalSheet))

<for loop here>
If country <> "" AND state_province <> "" AND city <> "" Then
    Do While Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").GetROProperty("Items count") < 2
        Wait(1)
    Loop
    Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").Select country

    Do While Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlState_Province.*").GetROProperty("Items count") < 2
        Wait (1)
    Loop
    Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlState_Province.*").Select state_province

    Do While Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlcity.*").GetROProperty("Items count") < 2
        Wait (1)
    Loop
    Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlcity.*").Select city
End If
<some other code>
<save entry>
<end for loop>

"Items count" < 2, while a crude method, works quite well for properly measuring the timing. Again, thank you for the help.

Incite1321
Reply
#6
Solved: 11 Years, 4 Months, 3 Weeks ago
Sometimes the old tricks are the best tricks.

You could adapt the code to retrieve the number of items earilier, then compare that value to the current value to see if its different...

Code:
currcount = Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").GetROProperty("Items count")

While Browser(dpBrowser).Page(dpPage).WebList("html id:=.*ddlCountry.*").GetROProperty("Items count") <= currcount
wait(1)
Loop

This might be a little more "reusable" and would allow for the standard "select something" type messages in a drop down. You could also adapt it to recognize if the "select something" messages were removed when repopulated or a number of other conditions.

Glad you have a working solution now.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare second web list value according to the first web list value roselin6 1 2,893 10-07-2015, 09:14 PM
Last Post: supputuri
  Drop-Downs in excel sheet indianinworld 1 3,729 03-01-2011, 08:40 PM
Last Post: indianinworld
  How to do DP for a site with multiple heirarchy? viv_karthy 1 1,710 05-13-2009, 04:32 PM
Last Post: tarunpandey4@gmail.com
  Drop-down box mahadevan.swamy 5 4,394 11-03-2008, 12:47 PM
Last Post: amilar
  Unable to Record Drop down Menu and it's list items samuluru 3 4,449 07-02-2008, 01:48 PM
Last Post: nageshpv

Forum Jump:


Users browsing this thread: 7 Guest(s)