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 values from a list

adsads Members
edited November -1 in Sahi - Open Source
I need to get the values(items) in a list.....like I need the correct spells in the list...

How is it possible?

Comments

  • narayannarayan Administrators
    What is this list identified as by Sahi? Is it a < ul > tag or < ol > tag?
    For ul and ol tags use _getText(_list("listId")) to get its contents.
  • Hi,

    A small example for this:
    for(var $i = 0; $i<_select("site").length; $i++)
         _alert(_getText(_select("site").options[$i]));
    

    Copy this code to your controller window and test it on this page.

    Regards,
    Pankaj
  • adsads Members
    Thanks for the many options....:)

    I tried with both...first one didn't work out....its a drop down where u can select for diff options.

    Pankaj this one worked and I could get the alerts...for each selection....is there any other way to

    get it printed in a result file...since I need to get the contents(correct spells).....
  • narayannarayan Administrators
    If you are using the latest build,

    _getText(_select("id"))

    will return an array of all options
  • Hi,

    If you want to log the values into the result file you can simply use the _log() in place of _alert()

    Regards,
    Pankaj
  • adsads Members
    Thanks Pankaj...

    Yes tried with log() and succees for _log(_getText(_select("lang"))); which logs "english" which is selected one presently.

    For, for(var $i = 0; $i<_select("lang").length; $i++)
    _log(_getText(_select("lang").options[$i]));

    not logging in results.How to get in with all values in the drop down?
  • sivasiva Members
    edited July 2011
    Hi Ads,

    i hope this code will help you

    ********************************************************************************

    var $arry_SubjArea = [];
    var val = _getText(_select("drpyear"))
    for(var $i = 0; $i<val.length; $i++) {
    _set($arry_SubjArea[$i], _getText(_select("drpyear").options[$i]));
    _log($arry_SubjArea[$i]);
    }


    ******************************************************************************
    OR
    ******************************************************************************


    var $arry_SubjArea = [];
    var val = _getText(_select("drpyear"))
    for(var $i = 0; $i<val.length; $i++) {
    _set($arry_SubjArea[$i], _getText(_select("drpyear").options[$i]));
    }

    for(var $i = 0; $i<$arry_SubjArea.length; $i++) {
    _log($arry_SubjArea[$i]);
    }

    ******************************************************************************


    Regards,
    Siva
Sign In or Register to comment.