How to get the value of the selected option?

Hello!

I use Katalon 5.4.2.

My xpath expression is :

id("A20")

I get the following select menu which contains 6 options.

<select id="A20">  
    <option value="1" selected>Select</option>
    <option value="2">1</option>
    <option value="3">2</option>
    <option value="4">3</option>
    <option value="5">4</option>
    <option value="6">5</option>
</select>

How is it possible with Katalon to get the value of the selected option? (without changing my xpath expression).

I didn’t found functions to do that, can you help me please?
Thank’s.

Use jquery:

def myVal = WebUI.executeJavaScript(‘return $("#A20").find(“option:selected”).val()’, [])

or try

def myVal = WebUI.executeJavaScript(’$("#A20").find(“option:selected”).val()’, [])

Hi @5173-crokatalontest

Thank’s a lot, the first solution seems to work fine !!!