-1

I'm trying to locate the element by XPath: I tried to add wait to load the page and also tried to scroll the page down. but same error

driver.findElement(By.xpath("//text()[contains(.,'Add portfolio')]/ancestor::a[1]")).click();

unknown error: Element ... is not clickable at point (326, 302). Other element would receive the click: ...

asmaa
  • 1
  • 2

3 Answers3

0
  1. Add ExplicitWait to wait for the element to be visible/clickable

     webDriverWait waitForElement = WebDriverWait(new TimeSpan(0, 0, 15));
     waitForElement.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(by));
    
  2. If there is any overlay that appears, ensure its closed since it might obstruct the element from getting the click
  • I tried this yes, same error. it seems another class gets the click.. is there any way to hide the class which get the click as in the error said – asmaa Jan 14 '19 at 08:43
  • could you provide html or share screenshot at the time of failure? – Anant Krish Jan 14 '19 at 09:19
  • it's worked when I added ...... driver.findElement(By.partialLinkText("Add portfolio")).sendKeys(Keys.RETURN); – asmaa Jan 14 '19 at 11:03
0

This might help you but make sure there is no alert or popup active in the window.

 WebDriverWait wait = new WebDriverWait(driver,60);
            wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_of_elm")));
     Actions action = new Actions(driver);
        action.moveToElement(driver.findElement(By.xpath("xpath_of_elm"))).click().build().perform();
sp324
  • 285
  • 2
  • 20
0

I would suggest you to use JavascriptExecutor click method here.

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);

If this is still not working, then check if there is any loading image there on the screen; you would be required to wait for that image to disappear in that case.

Tejas Jagtap
  • 11
  • 1
  • 3