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 to retrieve radio element text/value ?

bhimrajgbhimrajg Members
edited April 2009 in Sahi - Open Source
Hi,

I have radio button list on my webpage..I want to check if given string is part of radio button text or not.

For ex.

<input id="ctl00_ContentPlaceHolder1_radListOption_0" type="radio" name="ctl00$ContentPlaceHolder1$radListOption" value="Show All Opportunities (81)" checked="checked" />

I want to check if 81 exists in radio element value.
I am able to acess HTML object using _radio("ctl00_ContentPlaceHolder1_radListOption_0") but not sure how to get value out of it.

Can somebody help me please ?

Thanks.
Bhimraj

Comments

  • PriyaPriya Members
    Hi Bhimraj,

    check out this one
    _parentRow(_radio("ctl00_ContentPlaceHolder1_radListOption_0"),1).cells[2].getElementsByTagName("LABEL")[0].innerText.

    Here u will get the InnerText. Now u can compare it with your given Text data.
  • hi,

    use _radio("ctl00_ContentPlaceHolder1_radListOption_0").value to get the value of radio button and then use pattern matching techniques to assert the presence of the required text. Something like this:

    var $x;
    _set($x, _radio("ctl00_ContentPlaceHolder1_radListOption_0").value);

    then use $x.match(/81/) in your assertions.

    Regards,
    Pankaj.
  • Hi Priya & Pankaj,

    Thank you for your help. I tried _radio("ctl00_ContentPlaceHolder1_radListOption_0").value and it worked.

    Regards,
    Bhimraj
Sign In or Register to comment.