gpt4 book ai didi

java - 我无法获取以下 html 代码的 xpath

转载 作者:行者123 更新时间:2023-11-30 05:34:55 25 4
gpt4 key购买 nike

我正在尝试获取以下 HTML 代码的 XPath,但是

Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException 

发生错误

我试过了 -

 driver.findElement(By.xpath("//li/a[@href='#home']")).click();

HTML

<a class="nav-link active show" data-toggle="tab" href="#home" role="tab" aria-selected="true">
<svg class="olymp-register-icon">
<use xlink:href="top10allthings.com/theme/app/svg-icons/sprites/…">
<svg id="olymp-register-icon" viewBox="0 0 37 32">
<title> register-icon </title>
</svg>
</use>
</svg>
<div class="ripple-container"> </div>
</a>

最佳答案

看来您需要:

  1. 等到这个<div id="hellopreloader"消失
  2. 等待链接变为可点击

两者的答案都是Explicit Wait实现于Selenium Java client通过 WebDriverWait类(class)。

示例引用代码:

WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("hellopreloader")));
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#home']"))).click();

更多信息:How to use Selenium to test web applications using AJAX technology

关于java - 我无法获取以下 html 代码的 xpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56850452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com