Verify selected value in dropdown


I am using Katalon Recorder and I have a problem and I need your help.

I would like to either :

  1. capture the selected value from a dropdown list and compare it to an expression.

  2. to be able to do it all in 1, i.e. check directly the correspondence of the selected value with another one.

Here is what I had in mind but I can’t get the desired result.

storeEval | document.getElementById("select2-motifCollection_0_label-container").texContent; | text

if | ${text} = 'Option A'|
endif | |


How about:
if | ${text} == 'Option A'|

Using 1 equal sign is an equate, meaning ${text} now holds the contents ‘Option A’.
Using 2 equal sign is a comparison, meaning does ${text} holds contents that is the same as ‘Option A’.

Noticed a typo here, it uses ‘texContent’, not ‘textContent’, if this is incorrectly specified, then it’s likely it’ll never store the correct value in ‘text’.

But yeah, additionally, you need to follow what grylion54 said re equals signs, to perform the comparison successfully.