Can I use RegEx with Capybara?
I am trying to do somth like
fill_in \firstName" type="text" name="(\w+)" value=""\, :with => 'sdsdsd' Capybara answers
Сapybara::ElementNotFound: Unable to find field \firstName\" type=\"text\" name=\"(\w+)\" value=\"\"\
Wrong syntax?
Thanks in advance
You do not begin and end a regexp with backslashes \likeso\, you normally need slashes /likeso/. There is also the %r syntax that allows for different delimitors, see http://www.ruby-doc.org/core-2.0/Regexp.html
But all this does not apply in this case, because:
You cannot use a regexp as the first argument of fill_in, only a String. See the documentation at http://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Actions:fill_in
You can use either the id, name or the label-text to locate the input field, so just using "firstName" should work for you:
fill_in 'firstName', :with => 'sdsdsd'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With