WebDriver遇到Element is not currently visible and so ...解决

来源:互联网 发布:java servlet菜鸟 编辑:程序博客网 时间:2024/05/21 13:55
1、跑webdriver用例时遇到org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with

Command duration or timeout: 11 milliseconds,如下图:



2、定位这个元素时,遇到该异常:



3、刚开始用的id定位,就报这个异常,代码如下:

driver.findElement(By.id("billYear-plus")).click();

4、解决:最先想到的就是这个元素可能光使用id定位不到,所以尝试用xpath定位,果然成功了,代码如下:

driver.findElement(By.xpath("//div[@id='pop-up']//span[@id='billYear-plus']")).click();




0 0
原创粉丝点击