2

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"));
  }
}
6
  • Is it possible that there's an overlay (e.g. a loading mask) covering the element? That could intercept the click and the wait wouldn't recognize it (elementToBeClickable checks for visibility and the element being enabled). In that case, you would have to put there a wait till the mask is gone... Commented Sep 10, 2020 at 13:08
  • 1
    Most important part is after the 'Other element would receive the click: '. There is locator of overlapping element. Please update your question with page source code and full stack trace. Commented Sep 10, 2020 at 13:11
  • Share the URL so we could check de visible items. Commented Sep 10, 2020 at 13:42
  • The URL is globalrestructuringreview.com/survey/grr-100/2019 and I am trying to click one of the links under "firms" and then assert the login gate on page load. Commented Sep 10, 2020 at 14:13
  • 1
    The cookie bar is blocking furher clicks. I've changed the wait method a bit and this is working: ` driver.get("globalrestructuringreview.com/survey/grr-100/2019"); new WebDriverWait(driver, 30).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='optanon-allow-all accept-cookies-button']"))); driver.findElement(By.xpath("//button[@class='optanon-allow-all accept-cookies-button']")).click(); driver.findElement(By.xpath("//a[contains(text(),'Abe Ikubo & Katayama')]")).click();` Commented Sep 11, 2020 at 11:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.