4
使用Ruby,我們可以通過執行等具體因素如下:等到特定的元素消失
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.find_element(:class, 'gritter-item') }
但是如果我想特定元素從DOM消失了,我寫的方法,如:
def disappear_element
begin
driver.find_element(:class, 'gritter-item')
rescue Selenium::WebDriver::Error::NoSuchElementError
true
else
false
end
end
,並要求它像:
wait.until { disappear_element }
這樣我可以做到無元素。 Ruby中有沒有更好的方法來實現?
元素消失手段?我沒有明白你的觀點。 –
意味着期望元素未找到錯誤。在我的情況下,我想檢查popup元素一旦彈出消失就沒有找到。 – TDHM