0

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

Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
Vdev
  • 101
  • 1
  • 5
  • 17
  • have you tried waiting for some time and then performing the click? is the element hidden? – mkaran Aug 17 '16 at 08:02
  • no its a checkbox...i did try using wait but the input id is for the text next to the checkbox ,as when i identify the checkbox using firepath ,this line of html is highlighted( – Vdev Aug 17 '16 at 08:11
  • 1
    The problem is not on the xpath. You have a problem with another component overlaping your checkbox. Check this for possible reasons http://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error – Ricardo Vila Aug 17 '16 at 08:18

2 Answers2

1

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.

Cosmin
  • 2,354
  • 2
  • 22
  • 39
0

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
}
Paras
  • 3,197
  • 2
  • 20
  • 30
Rajkumar
  • 58
  • 5
  • i did try using wait but the input id is for the text next to the checkbox ,as when i identify the checkbox using firepath ,this line of html is highlighted( – Vdev Aug 17 '16 at 08:17