Application Link:– http://www.ufthelp.com/p/testpage.html
|DropDownlist + HTML code|
1.We would take the count of existing options in the weblist/dropdownlist .
2.Take a random value between 0(starting index of the dropdownlist, we can avoid in our case as we have –Select– at 0 index) and maximum value -1(total available options in the list)
3.Select the value based on the random value
Same logic would work whether we are using Selenium or UFT as our testing tool.
1.How to take count of items:-
a.We can use Findelements method to return a list of items and further we would use getSize method of list to fetch the count value.
b.We can use the Select Class and implement its getOptions method to get the count.
2.How to generate random number, we would implement “Random” class and use its nextInt method to output the random number between the given range.
Note:- nextInt, method would generate number from 0 to upperlimit-1, example nextInt(10), would generate numbers between 0 and 9.
1.For taking count of items, we would use GetRoProperty in UFT and pass “all items” to fetch the count
2. Random number is a Utility object , which generates random number between the given range