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.

Problem after getting the length of items in dropdwn list

vijaysaimsvijaysaims Members
edited November -1 in Sahi - Open Source
Hi,

I am facing a problem. In the following code I'm getting the count of items in a drop down list in the variable $Options. But cannot get into the loop.

$Options = _select("/ddlNoteType/").length;
_alert($Options);
for($i=1; $i <= $Options; $i++)
{
_alert($i);
}

What is the issue? Please help me.

Comments

  • Hi

    you will have to use _select("/ddlNoteType/").options.length;

    Regards
    Wormi
  • Hi Vijay,

    If you want all the dropdown lists then the code should be:
    _set($Options, _select("/ddlNoteType/").length);
    _alert($Options);
    for($i=1; $i <$Options; $i++)
    {
        _alert(_select("/ddlNoteType/").options[$i].text);
    }
    

    Check if this solves your issue.

    Regards
    Sumitra
  • Changed $Options = _select("/ddlNoteType/").length; to _set($Options, _select("/ddlNoteType/").length);. It worked. Thank You Sumitra
This discussion has been closed.