Reputation: 4207
I have a list of checkboxes and I need to find the checkboxes that have the attribute "checked". Below is how my check box element looks,
<input type="checkbox" class="u-display--inline-block u-margin-right--small" checked="">
How can I find this with xpath? I cannot use //input[@type='checkbox' and @checked='true')] because i don't have a checked value true attribute. Any advice would be much appreciated.
Upvotes: 0
Views: 1199
Reputation: 198
Kindly use below xpath for the same:
//input[@type='checkbox' and @checked]
Upvotes: 1
Reputation: 193108
To find the checkboxes that have the attribute checked
you can use either of the following solutions:
cssSelector:
"input.u-display--inline-block.u-margin-right--small[type='checkbox'][checked]"
xpath:
"//input[@class='u-display--inline-block u-margin-right--small' and @type='checkbox'][@checked]"
Upvotes: 1
Reputation: 89295
You can just mention the attribute checked
to test if it exists:
//input[@type='checkbox' and @checked]
Upvotes: 1