10-09-2009, 09:47 PM
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:
Is a way to solve this problem, other than increasing the wait time?
Thank you,
Incite1321
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