Java org.openqa.selenium.element点击拦截异常:element点击拦截:element<;a href="/url"></a>;在点(376846)处不可单击

Java org.openqa.selenium.element点击拦截异常:element点击拦截:element<;a href="/url"></a>;在点(376846)处不可单击,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我有一个自动脚本,我试图转到一个页面,单击一个链接,然后确保显示一个登录/注册门,因为我是一个匿名用户 由于找不到我的链接,我永远无法到达大门验证。我得到以下错误:org.openqa.selenium.element单击拦截异常:element单击拦截:element在点(376846)处不可单击。其他元素将收到单击: 我试图通过cssSelector和xpath的不同变体(绝对、相对等)来定位此链接 我发现了以下线索: 并尝试按照以下要求实施等待: 我不得不删除Duration.ofSec

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

由于找不到我的链接,我永远无法到达大门验证。我得到以下错误:org.openqa.selenium.element单击拦截异常:element单击拦截:element在点(376846)处不可单击。其他元素将收到单击:

我试图通过cssSelector和xpath的不同变体(绝对、相对等)来定位此链接

我发现了以下线索:

并尝试按照以下要求实施等待: 我不得不删除Duration.ofSeconds,因为这在Java3中似乎已被弃用。我还尝试了在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"));
  }
}
packagename;
导入org.junit.Test;
导入org.junit.Before;
导入org.hamcrest.matcherasert;
导入org.junit.After;
导入静态org.hamcrest.CoreMatchers.is;
导入org.openqa.selenium.By;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.remote.RemoteWebDriver;
导入org.openqa.selenium.support.ui.ExpectedConditions;
导入org.openqa.selenium.support.ui.WebDriverWait;
导入org.openqa.selenium.remote.DesiredCapabilities;
导入org.openqa.selenium.JavascriptExecutor;
导入java.util.*;
导入java.net.MalformedURLException;
导入java.net.URL;
公共类类名{
私有网络驱动程序;
JavascriptExecutor js;
@以前
public void setUp()引发畸形的DurException{
driver=新的RemoteWebDriver(新的URL(“webdriverurl”),DesiredCapabilities.chrome());
js=(JavascriptExecutor)驱动程序;
新的HashMap();
}
@之后
公共无效拆卸(){
driver.quit();
}
@试验
公共无效名称(){
获取驱动程序(“url”);
新WebDriverWait(驱动程序,(30))
.until(ExpectedConditions.elementToBeClickable(By.xpath(//a[contains(text(),'Abe Ikubo&Katayama'))))));
findElement(By.xpath(“//a[contains(text(),'Abe Ikubo&Katayama')])))。单击();
matcherasert.assertThat(driver.findElement(By.xpath(“//xpath”)).getText(),is(“text”);
}
}

是否可能有覆盖元件的覆盖层(如加载遮罩)?这可能会拦截单击,而等待将无法识别它(
elementtobelickable
检查可见性和启用的元素)。在这种情况下,您必须等待掩码消失……最重要的部分是在“其他元素将收到单击:”之后。有重叠元素的定位器。请使用页面源代码和完整堆栈跟踪更新您的问题。共享URL,以便我们可以检查不可见的项目。URL为,我正在尝试单击“公司”下的一个链接,然后在页面加载时声明登录门。cookie栏正在阻止更多的单击。我稍微改变了等待方法,这是有效的:`driver.get(“);new WebDriverWait(driver,30)。until(ExpectedConditions.elementtobelickable(By.xpath(//button[@class='optanon-allow-all accept cookies button']);driver.findElement(By.xpath(//button[@class='optanon-allow-all accept cookies button']))。单击();driver.findElement(By.xpath(“//a[contains(text(),'Abe Ikubo&Katayama')]”)`