If I run my scripts without first waiting for the element it moves to quickly and fails because the item is not available. The page I'm interacting with is HTML5/Angular. My questions is - is there a more efficient way to wait for an item, then click it? What I'm doing below works great but having to wait, then click, then wait for the next thing, then click over and over doesn't seem like the best way.
Setup:
def wait_for(timeout = 55)
Selenium::WebDriver::Wait.new(:timeout => timeout).until { yield }
end
def displayed?(how, what)
@driver.manage.timeouts.implicit_wait = 55
@driver.find_element(how, what).displayed?
end
Execution:
wait_for { displayed?(:xpath, "//div[text() = 'Previous Year']") }
@driver.find_element(:xpath, "//div[text() = 'Previous Year']").click