Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to get text of <label> tag which has "for" attribute  (Read 2753 times)

0 Members and 1 Guest are viewing this topic.

Prathiba

    Topic Starter


    Newbie
    • Experience: Familiar
    • OS: Windows 7
    How to get text of <label> tag which has "for" attribute
    « on: March 16, 2017, 01:50:37 AM »
    Hi All,

    I need to get the text of <label> tag which has "for" attribute but doesn't have id. There are many other similar nodes, with only the "for" attribute differing.
    I have 2 radio buttons, when i click on the radio button, i am fetching the id of the radio button selected. The id of the radio button is same as that of the "for" attribute of <label> tag. So, i want to use the id of radio button and compare it with the label tag and fetch the text.
     
    Here is the example node that contains the label w/ text I'm trying to select.
    <div>
    <span oclass=" required-marker label_description" style="margin-left: 1px;" assessable_id="891202b24fd9f200beb2e3518110c7c5" id="status.ASMTQUESTION:3d6686fe4fd9f200beb2e3518110c74b" allow_na="false" mandatory="false" class="changed required-marker label_description"></span>
    <label for="ASMTQUESTION:3d6686fe4fd9f200beb2e3518110c74b-0" title=" " data-original-title=" ">Text</label>
    <p>Expected Results</p> Result 02
    <input name="sys_original.ASMTQUESTION:3d6686fe4fd9f200beb2e3518110c74b" id="sys_original.ASMTQUESTION:3d6686fe4fd9f200beb2e3518110c74b" type="HIDDEN" class="questionSetWidget" value="">
    </div>
     
    Any help will be highly appreciated!!!
    Thanks in advance!!