更新时间:2023-11-25 22:40:10
实际上,如果找不到指定的元素,WebDriver的find_element方法将等待元素的隐式时间.
Actually WebDriver's find_element method will wait for implicit time for the element if the specified element is not found.
WebDriver中没有可检查的预定义方法,例如isElementPresent().您应该为此编写自己的逻辑.
There is no predefined method in WebDriver like isElementPresent() to check. You should write your own logic for that.
逻辑
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;
}
}
请参阅: http://goo.gl/6PLBw