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.

I want to loop through all items in a selectbox

supusupu Members
edited November -1 in Sahi - Open Source
May i know why this is not returning values.
var $all_Links = _collect("_Selectbox", "/./", _in(_div("searchDiv")));

Comments

  • Hi Supu,

    Try using :

    var $all_Links = _collect("_select", "/./", _in(_div("searchDiv")));

    Also, have a look at collect.sah script by navigating to
    sahi-home/userdata/scripts/demo/collect.sah

    Regards
    Smrithi
  • Hi supu,

    To loop through all the items in the selectbox, use something like,
    _set($length, _select("s1").options.length);
    for(var $i=0;$i<$length;$i++){
        _alert(_select("s1").options[$i].value);
        _alert(_getText(_select("s1")[$i]));
    }
    

    _collect API is used to collect all the elements of same type(eg.,link,selexbox) in the webpage and with your script, it wont collect all the options in the select box.

    Regards,
    Theeran.
  • Theeran, i agree whatever your saying and thanks for your answer.
    I got the solution from Smrithi, thanks a lot.

    Regards,
    Suputhra
Sign In or Register to comment.