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.

How do i get select a value from a drop down list

GeorgeGeorge Members
edited November -1 in Sahi - Open Source
OS : Windows 7
Broswer : firefox 7.0.1
Build: 2011-07-19

Hi

How do i select a text value (say the send value or the 5th value) from a dropdown list of say 10 values/names?
i tried the follwoing but it doesn't work.

_set($var2, _select("ctl00_ContentPlaceHolder1_ddlContactName").options.value);
_alert($var2);
_set($var2, _select("ctl00_ContentPlaceHolder1_ddlContactName").options.length);
_alert($var2);


pl advise

George

Comments

  • Hi George

    I think you should try with _setSelected() instead of _select in your code.


    thank you
    chinmaya
  • OrrinOrrin Members
    Hey George

    let's assume you have a dropdown with name="Title".....
    The first option is Blank followed by Mr, Mrs, Doc, Prof & Dr

    So, to select Doc:
    _setSelected(_select("Title"), "Doc");

    To select by index:
    _setSelected(_select("Title"), 3);

    REMEBER:
    Selecting based on index always starts from 0.

    Hope this helps.
    Orrin
Sign In or Register to comment.