lable tag with input inside it

Ask general questions here.
sstowe
Posts: 62
Joined: Thu May 31, 2018 2:26 pm

lable tag with input inside it

Post by sstowe » Mon Jul 23, 2018 7:10 pm

So I have rejoined the land of web automation after a long stint in desktop automation. Things have changed a bit. I have an <input inside a <label

<label class="checkbox-inline">
<input type="checkbox" name="entitled" data-bind="model">
Require approval from another user </label>

The input does not have a unique name (entitled is used by other label/input pairs on the page. the input is not exactly a child element of the label is it?

Any advice on how to address the input object of this page? Snapshot of the div containing this item and the others like it on the page attached. Thanks
Attachments
RolePermissions.rxsnp
(288.77 KiB) Downloaded 6 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: lable tag with input inside it

Post by Support Team » Mon Jul 23, 2018 8:53 pm

Hi sstowe,

While the input element does not have any unique attributes, the parent label does have a unique innertext attribute.

1.png
1.png (8.41 KiB) Viewed 160 times

Sample RxPath: (do not forget the leading and trailing white space)

Code: Select all

//label[@innertext='    Approve Payments ']/input
Result:
2.png
2.png (31.78 KiB) Viewed 160 times

I hope this helps!

Cheers,
Ned
.
Image

sstowe
Posts: 62
Joined: Thu May 31, 2018 2:26 pm

Re: lable tag with input inside it

Post by sstowe » Wed Jul 25, 2018 2:23 pm

It really does. In addition to helping me with this specific question, the light bulb has been turned on to what I have been failing to understand about xpath for a little while. Pretty simple, but it was still alluding me. Thank you.