这是我的剧本-
next=WDS.browser.findElement(pkg.By.xpath("//button[contains(@class,'btn btn-sm btn-light border ml-3')]"))
while(next.isEnabled()==true)
{
//java.lang.Thread.sleep(4000);
var wait19 =new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 9000)
wait19.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(pkg.By.xpath("//button[contains(@class,'btn btn-sm btn-light border ml-3')]"))).click()
next=WDS.browser.findElement(pkg.By.xpath("//button[contains(@class,'btn btn-sm btn-light border ml-3')]"))
//WDS.log.info(WDS.browser.getPageSource())
if (!next.isEnabled()) {
WDS.log.info('Next button disabled')
break
}
}在我的应用程序中,我需要访问总共300页并计算从第一页到最后一页遍历所需的时间。
但是,当单击next按钮时,它会抛出异常:
ERROR c.g.j.p.w.s.WebDriverSampler: element click intercepted: Element <button _ngcontent-pde-c133="" class="btn btn-sm btn-light border ml-3">...</button> is not clickable at point (226, 567). Other element would receive the click: <div _ngcontent-pde-c109="" class="overlay ng-tns-c109-11 ng-trigger ng-trigger-fadeIn ng-star-inserted ng-animating" style="background-color: rgba(0, 0, 0, 0.8); z-index: 99999; position: fixed;">...</div>
我该怎么解决呢?
发布于 2022-06-02 07:32:45
此错误意味着您要单击的按钮被某种形式的动画装载机/纺纱机“覆盖”,很可能显示数据已加载
您需要使用显式等待来等待,直到这个动画加载程序变得不可见,以便您能够单击该按钮。
将此行置于失败的行之前:
wait19.until(org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated(pkg.By.xpath("//div[contains(@class,'ng-animating')]")))它应该能解决你的问题。
更多信息:网络驱动程序采样器:您的十大问题答案
发布于 2022-06-03 11:13:37
最初,当WebDriver无法单击它想要单击的元素时,就会发生此问题。
在外包软件测试公司中,使用Action类解决了这个问题。例如,
Actions action = new Actions(driver);
action.moveToElement(element).click().perform();在这里,元素是我们要单击的定位器。
https://sqa.stackexchange.com/questions/50183
复制相似问题