How to get the text of label tag using for attribute

zvcxcxv
Kilo Contributor

Hi Everyone,

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><b>Expected Results</b></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!!