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 find value of radio type with the help of lable ?

chaudharypareshchaudharyparesh Members
edited June 2011 in Sahi - Open Source
My HTML Element Like :::

<td>

<input type="radio" checked="" onclick="changeBackupFrequency()" value="-1" id="mailloginterval" name="mailloginterval">
<label id="BackRes.Never">Never</label>
<input type="radio" onclick="changeBackupFrequency()" value="3" id="mailloginterval" name="mailloginterval">
<label id="BackRes.Daily">Daily</label>
<input type="radio" onclick="changeBackupFrequency()" value="2" id="mailloginterval" name="mailloginterval">
<label id="BackRes.Weekly">Weekly</label>
<input type="radio" onclick="changeBackupFrequency()" value="1" id="mailloginterval" name="mailloginterval">
<label id="BackRes.Monthly">Monthly</label>
</td>


Here User only give label name .

For example if user want to select 'Monthly' radio button then they need to give only Name of Radio button.

Here i want to found value from radio type element with the the help of label

eg. For Monthly i want to find value = 1 so from that i can write radio button syntax like
_click(_radio(1));


How ?

Comments

  • Try this - _click(_radio("1"));

    you forgot to put on quote("") for value. let me know you were requiring anything else.
  • Dear ashish

    i think you do not understand my problem. read again in that i mention i want to find value with the help of label name.
  • SumitraSumitra Members
    Hi Paresh,

    We are checking why _near is not working in this case. (Even if it did, since all the elements are in the same DOM parent, you will still need to use the index of 0,1,2,3 etc.)

    Just for information, the code above is quite wrong. The labels should be associated with radio buttons and the ids should be different for different radio buttons. (the name would be same for a given group).


    The code below is a corrected version:
    <input type="radio" checked="" onclick="changeBackupFrequency()" value="-1" id="mailloginterval1" name="mailloginterval">
    <label for="mailloginterval1" id="BackRes.Never">Never</label>
    <input type="radio" onclick="changeBackupFrequency()" value="3" id="mailloginterval2" name="mailloginterval">
    <label for="mailloginterval2"  id="BackRes.Daily">Daily</label>
    <input type="radio" onclick="changeBackupFrequency()" value="2" id="mailloginterval3" name="mailloginterval">
    <label for="mailloginterval3"  id="BackRes.Weekly">Weekly</label>
    <input type="radio" onclick="changeBackupFrequency()" value="1" id="mailloginterval4" name="mailloginterval">
    <label for="mailloginterval4"  id="BackRes.Monthly">Monthly</label>
    

    In the code above, the radio button would get clicked if you do _click(_label("Daily"));

    Regards,
    Narayan (from Sumitra's machine)
Sign In or Register to comment.