我正在尝试获取以下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>
答案 0 :(得分:1)
您似乎需要:
<div id="hellopreloader"
消失两者的答案是Explicit Wait通过Selenium Java client类在WebDriverWait中实现。
参考代码示例:
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