Why does Capybara "wait for page loading" seem to work as a timer, but not by search engines?

I am currently running a test that checks a specific item and then does some things. The element takes a bit for javascript to finish kicking, but within the timer I have Capybara for.

For some reason

assert session.has_xpath?(xpath_route) 

works fine but

 assert link=session.first(:xpath, xpath_route) 

does not work, saying that he cannot find the item. And fast - long before the wait timer ends.

I can only assume that this means that the timer only applies to helpers, not to searchers, which is good, but how can I make it keep searching until it finds the item I'm looking for?

+4
source share
1 answer

You correctly think that the timeout does not apply when using first . But you can use the wait_until method, which will continue to retry until the timeout expires or the block returns something plausible, therefore:

 page.wait_until() do session.first(:xpath, xpath_route) end 
+5
source

All Articles