Using Ruby, we can wait for a specific item by doing the following:
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.find_element(:class, 'gritter-item') }
but if I want some element to disappear from the DOM, I write a method like:
def disappear_element
begin
driver.find_element(:class, 'gritter-item')
rescue Selenium::WebDriver::Error::NoSuchElementError
true
else
false
end
end
and is called like this:
wait.until { disappear_element }
Thus, I could achieve the absence of an element. Is there a better way in Ruby to achieve the same?
source
share