Wait on a text to be appear in SitePrism Capybara Framework

2.5k Views Asked by At

I tried to wait on a text before perform any action by follows SitePrism URL https://github.com/natritmeyer/site_prism in this section>> "Methods Supporting Capybara Options".

@page.wait_until_<Element>_visible :text => "Some Text!!!"

But i am getting below error:

undefined method `zero?' for {:text=>"Some Text!!!"}:Hash (NoMethodError)

Why i am getting this error? Am i doing something wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

Looking at the site_prism code - https://github.com/natritmeyer/site_prism/blob/master/lib/site_prism/element_container.rb#L134 the generated method takes a timeout, and the options. It seems like you need to pass the timeout value if you want to pass other options

wait_until_<Element>_visible <timeout value in seconds>, text: "Some Text!!!" 

Seems like an error in the documentation, or some old defaulting behavior was removed or something

2
On

Old question

For those still hitting this SO answer, this has been remedied in v3 of the API and is no longer an issue. See: https://github.com/natritmeyer/site_prism/blob/master/UPGRADING.md#wait_until-methods

wait_for_ methods now no longer exist, and you should just implicitly wait by calling element i.e. my_button

If you want it to wait, you can modify the Capybara.default_wait_time or pass in a wait key i.e. my_button(wait: 3)