在几次 GUI 操作后尝试验证某些按钮不存在(预计不存在)。我正在使用 find_element_by_xpath() 但它非常慢。超时有什么解决办法吗?
实际上,如果未找到指定的元素,WebDriver 的 find_element 方法将等待该元素的隐式时间。
WebDriver 中没有像 isElementPresent() 这样的预定义方法来检查。您应该为此编写自己的逻辑。
Logic
public boolean isElementPresent()
{
try
{
set_the_implicit time to zero
find_element_by_xpath()
set_the_implicit time to your default time (say 30 sec)
return true;
}
catch(Exception e)
{
return false;
}
}
See : http://goo.gl/6PLBw
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)