Micro Focus QTP (UFT) Forums
Random Values from Drop-Down - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Random Values from Drop-Down (/Thread-Random-Values-from-Drop-Down)



Random Values from Drop-Down - profqa - 12-06-2013

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


RE: Random Values from Drop-Down - basanth27 - 12-06-2013

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.



RE: Random Values from Drop-Down - profqa - 12-06-2013

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.


RE: Random Values from Drop-Down - basanth27 - 12-06-2013

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?


RE: Random Values from Drop-Down - profqa - 12-06-2013

Thanks Basanth! This is what I was looking for since morning.


RE: Random Values from Drop-Down - basanth27 - 12-06-2013

Happy to Help Smile Most Welcome.