How to select any random value from a dropdown?
问题 I am working on selenium using Java. In my application I want to select any random value from the dropdown. Please tell how is it possible? 回答1: Well, first get the total number of items in the dropdown. Then generate a random number between 0 and dropdown items count. Then select that number as index to set your dropdown item 回答2: Use getSelectOptions to get an array of options of the select box. Then generate a random integer between 0 (inclusive) and the length of the array (exclusive).