ExpectedConditions.invisibilityOfElementLocated不起作用 [英] ExpectedConditions.invisibilityOfElementLocated doesn't work

查看:94
本文介绍了ExpectedConditions.invisibilityOfElementLocated不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id(".....")));
webDriver.findElement(By.xpath(".......")).click();

有时候我会得到例外:

org.openqa.selenium.WebDriverException: unknown error: Element <a href="#" onclick="showRelatedPerson();return false;" class="button-alt button-icon">...</a> is not clickable at point (1233, 710). Other element would receive the click: <div id="jquery-msg-bg" style="width: 100%; height: 100%; top: 0px; left: 0px;"></div>

这是我试图通过等待而避免的元素.我一直等到它变得不可见,但是有时即使它变得不可见,它仍然可以接收到点击,并且阻止了要单击的适当元素.

This is the element that I am trying to avoid by wait that I put. I am waiting until it becomes invisible, but sometimes even if it becomes invisible it still can receive the click and it is blocking the proper element to be clicked.

推荐答案

问题是,一旦测试到达第一行,我等待不可见的元素仍然不可见,但是随着测试的完成,该行元素变为可见.因此解决方案是在开头再添加一行:

The problem was that once test reaches first line, the element that I wait to be invisible was not visible yet, but as test completes this line element becomes visible. So the solution was to add one more line at the beginning:

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("jquery-msg-bg")));
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("jquery-msg-bg")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("declarationBusinessParticularsActivity.isMain")));

这篇关于ExpectedConditions.invisibilityOfElementLocated不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆