Vdev Vdev - 3 months ago 18
HTML Question

Proper xpath for identifying the checkbox

I am trying to write an selenium script using

xpath
to
click
on the checkbox but am unable to perform the operation rather i am getting an error


Element is not clickable at point (210.5, 616). Other element would receive the click: Command duration or timeout: 75 milliseconds


html:

<div style="float:left;">
<label class="enhanced-checkbox" for="lender_user_privacy">
<i class="icon"/>
</label>
<input id="lender_user_privacy" class="ui-helper-hidden-accessible" type="checkbox" value="1" required="required" name="lender_user[privacy]"/>
</div>


xpath:

driver.findElement(By.xpath("//input[@id = 'lender_user_privacy']")).click();


Note: Could you suggest me the right
xpath
for clicking on the checkbox as i am getting the above error when i write the above
xpath

Answer

Considering the comment, to navigate back to the parent you can use xpath's parent expression /... If .//input[@id='lender_user_privacy'] is identifying you the label, that' a child of the checkbox, then you can access the checkbox using

.//input[@id='lender_user_privacy']/..

as your xpath. However, the wait is most likely necessary considering the error that you're getting.

Comments