-2

Clicking on links is not working and is showing below error. I tried using both Xpath and Linktext

Code

driver.findElement(By.linkText("Repayment Options")).click();
driver.findElement(By.xpath(".//*@id='menucontent']/div/nav/ul/li[6]/a")).click();

Error

"Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element
<a href="/RepaymentOptions/RepaymentOptions">...</a> is not clickable at point (312, 404).
Other element would receive the click:<div class="modal-backdrop fade"></div>"
JeffC
  • 22,180
  • 5
  • 32
  • 55
johnsonambrose
  • 115
  • 1
  • 2
  • 15
  • are you sure the path is right? – strash Apr 10 '17 at 20:25
  • Welcome to Stack Overflow! Please [take the tour](http://stackoverflow.com/tour) to see how the site works and what questions are on topic here. – Joe C Apr 10 '17 at 20:28
  • Possible duplicate of [Debugging "Element is not clickable at point" error](http://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error) – SiKing Apr 10 '17 at 20:52

2 Answers2

1

If you're facing any abnormal difficulty which you are not able to handle directly , then you can first try to move to that element using actions class then click it as below:

 WebElement we = driver.findElement(By.cssSelector("#menucontent > div > nav > ul > li:nth-child(6) > a");
 Actions action = new Actions(driver);
 action.moveToElement(we).click().build().perform();
Kushal Bhalaik
  • 3,349
  • 5
  • 23
  • 46
0

If you carefully look at the error, it tells you what the problem is. Selenium is trying to click on the element you requested but it's currently blocked by another element. If you look at the HTML for the element that would have received the click, you will see

<div class="modal-backdrop fade"></div>

That's likely a translucent background behind a dialog that is currently up or maybe you just dismissed but the browser was a little slower than your code. One way around this is to wait for this modal backdrop to disappear. You can do this like

new WebDriverWait(driver, 3).until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div.modal-backdrop")));
driver.findElement(By.linkText("Repayment Options")).click();
driver.findElement(By.xpath(".//*@id='menucontent']/div/nav/ul/li[6]/a")).click();
JeffC
  • 22,180
  • 5
  • 32
  • 55