How to select any random value from a dropdown?

后端 未结 4 1192
迷失自我
迷失自我 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:19

    What Sachin said. I know often it's good to get an actual code reply, so assuming you're working with a JComboBox:

    comboBox.setSelectedIndex(new Random().nextInt(comboBox.getItemCount()));

    The class Random can be found in the java.util package.

提交回复
热议问题