#28 ✓duplicate
rssaddict

NULL pointer given (ArgumentError) when label tag doesn't wrap around input tag -- fills_in

Reported by rssaddict | November 10th, 2008 @ 09:35 PM

If you have a form tag that looks like:


< form >
  < label for="email" name="email" >Email< /label >
  < input type="text" id="email" >< /input >
< /form >

Webrat will throw an error when you call fills_in('Email', :with => 'whatever'):


NULL pointer given (ArgumentError)
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/field.rb:106:in `name'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/field.rb:106:in `label_elements'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/field.rb:97:in `labels'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/field.rb:44:in `matches_label?'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/form.rb:64:in `field_labeled'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/form.rb:63:in `select'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/form.rb:63:in `field_labeled'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/locators.rb:31:in `find_field_labeled'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core_extensions/detect_mapped.rb:5:in `detect_mapped'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core_extensions/detect_mapped.rb:4:in `each'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core_extensions/detect_mapped.rb:4:in `detect_mapped'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/locators.rb:30:in `find_field_labeled'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/locators.rb:15:in `field_labeled'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/locators.rb:10:in `field'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/scope.rb:183:in `locate_field'
      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/scope.rb:41:in `fills_in'

If the label tag is wrapped around the input instead, like:



< form >
  < label for="email" name="email" >Email
  < input type="text" id="email">< /input >< /label >
< /form >

it works fine.

I tried commenting out the code on lines 104 to 111 of field.rb in webrat/core and it seems to solve my problem. I can't exactly figure out what that code was meant to do, obviously it's there for some reason, but I can't seem to fix this bug on my own.

If there's anything else I can help with let me know.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages