Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to select dynamic option of an object in run time?
#1
Solved: 11 Years, 4 Months ago
Hi everyone,

I am a new person using QTP to develop test script. I am writing the test script to verify adding some products with different options to a cart of web application. I wonder how to identify dynamic options of these products in run time. I used datatable with the column "ProductID" which is described as inputted parameter. It means that I only input the static Product ID from the datatable to "Search" field of web page and I want to execute the script to automatically select an option item in each group from the specified Product ID (not to select a specified option as below and I also don't want to input static options into datatable) then add it to the cart. Please help me find a way to solve it.

Here are some recorded scripts when using the Record functionality:

Code:
Browser("IE").Page("Shopping site").WebEdit("keywords").Set DataTable("ProductID", dtGlobalSheet)
Browser("IE").Page("Shopping site").Image("find our site").Click 8,5
Browser("IE").Page("Product").WebEdit("qty").Set "3"

'it means that I select the option item 1 from option group 1 "id[MGP915]"
Browser("IE").Page("Product").WebList("id[MGP915]").Select "Amber Color"
'it means that I select the option item 2 from option group 2 "id[MGP899]"
Browser("IE").Page("Product").WebRadioGroup("id[MGP899]").Select "OPT3522"
Browser("IE").Page("Product").Image("In Cart").Click 91,12
Browser("IE").Page("Product").Sync
Browser("IE").Close
'end script.

Many thanks to quick reply for this case.
BR
#2
Solved: 11 Years, 4 Months ago
Hi

Could you please attach the screen of your issue.

Thanks,
Azeem
#3
Solved: 11 Years, 4 Months ago
Hi Azeem,

Thanks for your quick reply and I am sorry for making you confused when reading this topic with unclear issue.

Below is an example to add a product to cart (Each product has different options which we only see during run time)

Example:
Step 1. Launch to the website "http://www.lockersupply.com"
Step 2. Input a product code, such as LW1376, into Search field.
Step 3. Click on "Search" button.
Step 4. Select all options for the product if any (For example, select 3 options for Product "LW1376")
Step 5. Input a number into Qty field.
Step 6. Click on "Add to Shopping Cart" button

At Step #3, the number of options varies based on the product code, i.e. there is none, one, or more than one option for a product. So, I want to have a script which is able to automatically select all the possible options of a product, i.e. if a product has 4 options, then 4 of them should be chosen.

BR,
joshasha
#4
Solved: 11 Years, 4 Months ago
Can depend on the option object, but assuming its a checkbox list or something, you can do an item count (.GetROProperty("item count")) then do a loop to select each item (.GetItem(x)). Sorry I don't remember the exact code.

GL.
#5
Solved: 11 Years, 4 Months ago
Yes, thats the best approach.

1. First Find the Object ( I guess in your case it is a weblist ).
2. Find the number of items in the object ( getroproperty("itemscount") )
3. Use For loop to iterate between the count ( For i =1 to itemcount)
4. Select the item based on the index cummulatively (for eg : Select(i) )

Sample Code,

Code:
itemcount = Browser("IE").Page("Product").WebList("id[MGP915]").GetRoproperty("itemscount")

For i = 1 to itemcount
   Browser("IE").Page("Product").WebList("id[MGP915]").Select i
Next

Does this help ?
@Azeem - Can you explain your true intention behind the screenshot ?
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.
#6
Solved: 11 Years, 4 Months ago
Hi,
with the below code u would be able to identify how many list box has been displayed dynamically
Code:
Browser("Lockers, Storage Lockers,").Page("Lockers, Storage Lockers,").WebEdit("keyword").Set ("LW1368")
Browser("Lockers, Storage Lockers,").Page("Lockers, Storage Lockers,").WebButton("Search").Submit
wait(10)
Set a=Description.Create
a("html tag").value="SELECT"
Set b=Browser("Lyon - Work Bench with").Page("Lyon - Work Bench with").ChildObjects(a)
c=b.count
msgbox c 'Here u will be able to identify how many attributes list has been displayed


Please find the attached Object Repository also , it may helpful to u
I am attaching OR.doc (As because this site is not accepting .tst files so i changed it to .doc , if u wnat to see this please change it to .tsr and upload it to your object repository)
Please let me know if u need any information apret from this...


Attached Files
.doc   OR.doc (Size: 240 KB / Downloads: 108)
#7
Solved: 11 Years, 4 Months ago
Woah..Woah..Woah...Mr.VenkatBatchu, would you please read the post clearly before stashing data into it ?

What is the necessity to attach a OR ?

Secondly, please please please, use formatted code.
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.
#8
Solved: 11 Years, 4 Months ago
I have gone through the query and posted the query , please check it once again
Here for different number of product id's
Displaying list boxes will be vary (some times it will be 3 , some times it will be 2, some times it will not show any thing)
When it display the list boxes she has to select some values from those list boxes that is the requirement......
I have gone through the query and posted the my suggestion , please check it once again
Here for different number of product id's
Displaying of list boxes will be vary (some times it will be 3 , some times it will be 2, some times it will not show any thing)
When it display the list boxes she has to select some values from those list boxes that is the requirement...... (dynamically these number of list boxes will vary....)
#9
Solved: 11 Years, 4 Months ago
It is about the values in the listbox not the listbox itself.
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.
#10
Solved: 11 Years, 4 Months ago
I greatly appreciated your reply for solving my facing trouble. However, I have a little difficulty in indentifying the ID numbers of the option groups of an arbitrary product. In my previous post, I just simply chose the two option groups of product A, MGP915 & MGP899. In fact, the set of option groups varies for each product, i.e. each product has a different set of option groups (different types & number). So, Is there any way to identify this kind of dynamic data or we have to write a query in database to get the product's option groups?

Thanks all for your help,
joshasha.

Code:
itemcount = Browser("IE").Page("Product").WebList("xxxxxx").GetRoproperty("itemscount")
For i = 1 to itemcount
   Browser("IE").Page("Product").WebList("xxxxxx").Select i
Next


Possibly Related Threads…
Thread Author Replies Views Last Post
  swfwindow object name getting changed after each run saniya 1 1,686 10-10-2018, 09:02 PM
Last Post: TheGlovner
  Object Name Is Also A Dynamic Value zunebuggy 0 1,147 05-16-2017, 09:53 PM
Last Post: zunebuggy
  Object identification is taking too much time JACKSPARROW 0 1,701 01-17-2017, 11:08 AM
Last Post: JACKSPARROW
  QTP not recogonising object during run time Lavanya N 2 3,727 10-28-2015, 12:46 PM
Last Post: vinod123
  Writing to Run time data table Neetha 5 12,175 08-27-2015, 10:18 AM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 4 Guest(s)