2012-10-09 78 views

回答

7

實際上,如果未找到指定的元素,WebDriver的find_element方法將等待元素的隱式時間。

WebDriver中沒有預定義的方法,例如isElementPresent()來檢查。你應該爲此編寫自己的邏輯。

邏輯

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

相關問題