Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex for Capybara

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

like image 624
Alex Avatar asked Mar 04 '26 04:03

Alex


1 Answers

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'
like image 165
bjelli Avatar answered Mar 06 '26 16:03

bjelli