org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素<a href="/url"> ... </a>在点376,846不可点击

问题描述

我有一个自动脚本,试图转到页面,单击链接,然后确保显示登录/注册门,因为我是匿名用户。

由于无法找到我的链接,因此我无法进行登机验证。我收到以下错误:org.openqa.selenium.ElementClickInterceptedException:元素单击被拦截:元素...在点(376,846)不可单击。其他元素将获得点击:

我试图通过cssSelector和xpath的不同版本(绝对,相对等)来定位此链接。

我发现了以下线程:

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

并且已尝试按照https://www.selenium.dev/documentation/en/webdriver/waits/#explicit-wait执行等待 我不得不删除了Duration.ofSeconds,因为Java 3中似乎已弃用了它。我还尝试了在获得URL之后和找到元素之后直接进行等待。

我也尝试了隐式等待。我仍然遇到相同的错误。我是Java的新手,所以可以提供一些帮助!

这是我的代码:

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"));
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...