您的位置:首页 > 其它

Webdriver Element is not currently visible 解决方法

2015-11-27 18:11 706 查看
转载地址:http://blog.sina.com.cn/s/blog_505bf9af0101bdtq.html

Element is not currently visible and so may not be interacted with 解决方法

先看截图:

Webdriver Element is not currently visible 解决方法

在Firebug中对应的html源码,见高亮显示。

Webdriver Element is not currently visible 解决方法

如果用:

driver.findElement(By.className(“cancelBtn”)).click();

或 driver.findElement(By.id(“save_btn”)).click();

就会报“Element is not currently visible and so may not be interacted with”错误

解决方法:

思路: 使用 findElements遍历,input标签,然后找到share按钮对应的 索引值,然后再操作。

List element=driver.findElements(By.tagName(“input”));

for(WebElement e:element)

{

System.out.println(e.getAttribute(“id”));

}

element.get(78).click();

至此 问题解决。

问题更正: 此种问题的关键是在于用className和id都不唯一所以找不到对象,改为:

driver.findElement(By.xpath(“//input[@value=’Share’]”)).click();同样可以解决问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: