How to select any random value from a dropdown?

后端 未结 4 1116
迷失自我
迷失自我 2021-01-21 18:57

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?

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 19:06

    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).

    Then use select with an index locator to select the randomly chosen option.

提交回复
热议问题