Webrat error on form submit
I was getting a bizarre error from Webrat:
And I press "Next" # features/step_definitions/webrat_steps.rb:10
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.submit (NoMethodError)
(eval):2:in `click_button'
./features/step_definitions/webrat_steps.rb:12:in `/^I press "(.*)"$/'
features/choosing_varieties.feature:39:in `And I press "Next"'It turns out, my HTML tags were not nested properly… I had a <table><form></table></form> kind of situation. If you’re getting an error like this, try validating your HTML.
May 16th, 2009 at 9:42 am
Erik - thank you very much for making the effort to write this. You just saved me hours. The only other google result was a lighthouse ticket saying the error comes from having no form. I had a form_for, but I started a div inside the form_for and closed it after the end.
May 16th, 2009 at 11:18 am
[...] the form_for block and closed after the end. I fixed that and now cucumber is all green. Thanks to this post for pointing to the [...]
August 5th, 2009 at 3:19 pm
Thanks! This saved my head from being hit against the wall repeatedly.
October 2nd, 2009 at 8:41 am
Merci
It’s help me a lot
November 22nd, 2009 at 6:45 pm
thx for sharing this!!
January 19th, 2010 at 10:15 am
my code passed html validation 401 strict, but I had a button without a surrounding form :
once I changed to :
It was ok
July 26th, 2010 at 1:48 am
[...] being able to decipher that, I turned to the web and found this helpful link which didn’t completely solve my problem but did point me in the right direction: check the [...]