org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <a href="/url">...</a> is not clickable at point (376, 846)

Viewed 629

I have an automated script where I am trying to go to a page, click a link and then make sure a login/registration gate is displayed because I am an anonymous user.

I can never get to the gate validation as my link cannot be found. I get the following error: org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element ... is not clickable at point (376, 846). Other element would receive the click:

I have tried to locate this link by cssSelector and different variations of xpath (absolute, relative etc).

I have found the following thread:

ElementClickInterceptedException: Message: element click intercepted: Element <label> is not clickable with Selenium and Python

And have tried to implement a wait as per: https://www.selenium.dev/documentation/en/webdriver/waits/#explicit-wait I had to remove Duration.ofSeconds as this seems to be deprecated in Java 3. I also tried the wait straight after the url get and after finding the element.

I also tried an implicit wait. I still get the same error. I am new to Java so some help would be appreciated!

Here's my code:

package packagename;

import org.junit.Test;
import org.junit.Before;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import static org.hamcrest.CoreMatchers.is;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.JavascriptExecutor;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class classname {
  private WebDriver driver;
  JavascriptExecutor js;

  @Before
  public void setUp() throws MalformedURLException {
    driver = new RemoteWebDriver(new URL("webdriverurl"), DesiredCapabilities.chrome());
    js = (JavascriptExecutor) driver;
    new HashMap<String, Object>();
  }
  @After
  public void tearDown() {
    driver.quit();
  }
  @Test
  public void name() {
    driver.get("url");
    new WebDriverWait(driver, (30))
        .until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(text(),'Abe Ikubo & Katayama')]")));
    driver.findElement(By.xpath("//a[contains(text(),'Abe Ikubo & Katayama')]")).click();
    MatcherAssert.assertThat(driver.findElement(By.xpath("//xpath")).getText(), is("text"));
  }
}
0 Answers
Related