I'm currently running a test that checks for a specific element and then do some stuff to it. The element takes a little for the javascript to finish kicking in, but well within the timer I've got Capybara set for.
For some reason
assert session.has_xpath?(xpath_route)
works fine, but
assert link=session.first(:xpath, xpath_route)
fails, saying it could not find the element. And quickly - long before the wait timer would run out.
I can only assume this means the timer only applies to matchers, not finders, which is fine, but how can I force it to keep looking until it finds the element I'm looking for?
You are correct assuming that the timeout does not apply when using
first
. But you can use thewait_until
method, which will keep retrying until either the timeout expires, or the block returns something truthy, so: