Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Values from Drop-Down
#1
Solved: 10 Years, 10 Months, 3 Weeks ago
How I can choose a random value from a drop-down?

Example:
Browser("e.........Login").Page("...........").WebList("Manufacturer").Select "ABC"

I want to select different values from manufacturer drop-down
Reply
#2
Solved: 10 Years, 10 Months, 3 Weeks ago
Parameterize your input.
Code:
strVal = "ABC"
Browser("e.........Login").Page("...........").WebList("Manufacturer").Select strVal

Or you may,
Code:
Find "AllItems" and store it in an "Array"
Loop using a "For Next" and Check if it is the desired string and Select the required Item.
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.
Reply
#3
Solved: 10 Years, 10 Months, 3 Weeks ago
Thanks basanth27 ! I appreciate your quick response.
For option 1: variable strVal have value “ABC” So it is not random, manufacture value will remain “ABC”. I want to select different values every time I run my script

For Option2: It is selection all the values from the drop-down.
Reply
#4
Solved: 10 Years, 10 Months, 3 Weeks ago
If your case is that you dont care what the value is selected then you may use the RandomNumber and assign that value as an index to be selected.
Let's say you have 20 manufacture's names in the dropwdown and you have to select anything each time you run the script.
Code:
sRandNum = RandomNumber(1,20)
Browser("e.........Login").Page("...........").WebList("Manufacturer").Select sRandNum
Does this help?
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.
Reply
#5
Solved: 10 Years, 10 Months, 3 Weeks ago
Thanks Basanth! This is what I was looking for since morning.
Reply
#6
Solved: 10 Years, 10 Months, 3 Weeks ago
Happy to Help Smile Most Welcome.
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to verify the drop down values based on condition santhoshmscsoftware 1 2,912 05-04-2016, 11:28 PM
Last Post: supputuri
  Drag and drop issue excellentpawan123 0 2,746 01-13-2015, 05:04 PM
Last Post: excellentpawan123
  Drop down list class is a link thotamurali 2 4,195 08-22-2014, 05:48 PM
Last Post: thotamurali
  Create a random number starting with an alphabet QTPmate 4 4,192 07-31-2014, 09:29 AM
Last Post: QTPmate
  Selecting values from drop down using QTP. prempujaripati 2 46,768 06-26-2014, 06:06 PM
Last Post: rasmirani

Forum Jump:


Users browsing this thread: 1 Guest(s)