2

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?

ASM
  • 709
  • 2
  • 8
  • 27
  • If you go to the given url section ("Methods Supporting Capybara Options") which i provided, you will see the sample code there. I corrected my question, sorry. – ASM Feb 11 '16 at 18:20
  • 1
    Ok - so 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 -- so it seems like you need to pass the timeout value if you want to pass other options : `wait_until__visible , text: "Some Text!!!" ` - seems like an error in the documentation, or some old defaulting behavior was removed or something – Thomas Walpole Feb 11 '16 at 18:42
  • 1
    @Tom - It worked!!! Thanks Tom – ASM Feb 11 '16 at 20:09
  • You might want to file an issue on the site_prism project about the README being wrong - and I've added my comment as an answer so you can mark the question answered – Thomas Walpole Feb 11 '16 at 20:09

2 Answers2

1

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

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78
0

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)

Luke Hill
  • 460
  • 2
  • 10
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/22280858) – Alain Merigot Feb 22 '19 at 21:37
  • That's not going to happen because that link will be perm as an upgrading guide. But fair point I'll amend accordingly. – Luke Hill Feb 25 '19 at 09:01