Reputation: 103
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
Upvotes: 0
Views: 324
Reputation: 58
xpath seems to be correct. Use explicit wait. Following code is in c#:
try {
WebDriverWait wt;
wt = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
wt.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.xpath("//input[@id='lender_user_privacy']")))).Click();
} catch(WebDriverException) {
// do some actions on exception if you want
}
Upvotes: 0
Reputation: 2394
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.
Upvotes: 1