ExpectedConditions.invisibilityOfElementLocated doesn't work

孤者浪人 提交于 2021-01-27 13:40:43

问题


I have this code

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

Sometimes I get exception:

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.


回答1:


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")));


来源:https://stackoverflow.com/questions/42836656/expectedconditions-invisibilityofelementlocated-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!