How to Get Select Option Value?

Hello, I’m new in automation testing, and I have a question

So I have dropdown like this

Instead of getting Value A, AB, B, O
Can I get Value 1, 2, 3, 4 from full path?

So I use random number to click random option in dropdown & combo box, but I don’t want to click selected option again, If I can get value by number I can add validate output: Output value not equals to the current number

Thank you

Hi @jefri.sinatra

You can use a dynamic element and replace the index of the element with a parameter and create a parameter with a random number within a range(it can start from 0 or 1 - depending on your application), for ex:

On each run, it will get a different random value and thus click on a different element.

To be sure that the new random number is different than the last one, you can add these steps:

  • First, let’s create a new parameter, in addition to the “randnumber” we already created. Let’s call it “old_num”

  • Then, let’s use the action “set value to a parameter” and set the old value to the parameter:

  • Now, we should put this step before the “random in a range” step.

  • Finally, let’s add the condition to the generate number step:

Note: You should add a default(and differents) values to each parameter.

Feel free to let us know if you need more help.

Kind regards,

1 Like

This topic was automatically closed after 180 days. New replies are no longer allowed.