18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Get list of option values inside 'select' element

xmenmgxmenmg Members
edited November 2011 in Sahi - Open Source
Hello,

I'm developing sahi with java driver. In the web page, I have this select:

<select name="mySelect">
<option value="aaa">aaaValue</option>
<option value="bbb">bbbValue</option>
<option value="ccc">cccValue</option>
</select>

What I want is to retrieve the value of list options inside this select ? Please show me if any way to do this.

I think the ElementStub class should have something like: getElements("option") and to return a list of child elements.

Comments

  • I have found solution, something like:

    Integer optionsNum = Integer.valueOf(browser.fetch("_sahi._select('" + selectName + "').options.length"));

    for (int i=0; i< optionNum; i++) {
    String label = browser.option(i).getValue();
    }
This discussion has been closed.