#162 ✓out-of-date
Jeff Dean

response is nil in selenium mode

Reported by Jeff Dean | February 11th, 2009 @ 10:35 PM

When running cucumber with selenium, response is always nil for me. My current setup is:

Gems

  • webrat (0.4.1)
  • cucumber (0.1.16)
  • selenium-client (1.2.10)
  • rspec (1.1.12)
  • rspec-rails (1.1.12)
  • nokogiri (1.1.1)

env.rb


ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support

require 'webrat'
require 'webrat/rails'

require 'cucumber/rails/rspec'
require 'webrat/rspec-rails'
require 'webrat/core/matchers'

require 'fixjour'
require 'faker'

require File.join(RAILS_ROOT, "spec", "object_creation_methods")

Dir["spec/spec_helpers/**/*.rb"].each do |file|
  require_dependency file # just a table truncation script
end

include Fixjour
include TruncateTables

selenium.rb


require "webrat/selenium"
 
Webrat.configure do |config|
  config.mode = :selenium
end
 
Before do
  truncate_tables!
end

Executing with


cucumber -r features/support/env.rb -r features/support/selenium.rb -r features/step_definitions features/people.feature

When I run the command above, the browser opens, the "visit" steps work, clicking links works and all other action steps work, but response is nil. The error I get is:

Error Message


Then I should see "Please enter a search term and try again."
      You have a nil object when you didn't expect it!
      The error occurred while evaluating nil.body (NoMethodError)
      ./features/step_definitions/webrat_steps.rb:90:in `Then /^I should see "(.*)"$/'

When I run it in rails integration mode, the story passes. This worked a few days ago, and I must have upgraded some gem, or changed something in my environment but I can't figure out what. What version of selenium-rc is webrat selenium tested against?

Comments and changes to this ticket

  • Jeff Dean

    Jeff Dean February 11th, 2009 @ 11:27 PM

    I can access the response_body, and response.body, by going through the webrat_session, like so:

    
    Then /^I should see "(.*)"$/ do |text|
      webrat_session.response.body.should contain(text)
      # The original step that shipped with the latest version of cucumber was:
      # response.body.should =~ /#{text}/m
    end
    

    For some reason all of the regular expressions seem to not be working, and I have to put several sleep statements before the response is returned, but at least I have something now. I still can't figure out what changed from the version that works.

  • gaffo

    gaffo May 7th, 2009 @ 03:17 PM

    • Tag set to stale, verify
    • State changed from “new” to “open”

    Jeff, It's been a while so I'm just checking if this is still an issue. Please let us know.

  • gaffo

    gaffo May 7th, 2009 @ 03:18 PM

    • Tag changed from stale, verify to selenium, stale, verify
  • gaffo

    gaffo June 3rd, 2009 @ 10:36 AM

    • State changed from “open” to “out-of-date”
  • nepavewyc

    nepavewyc January 12th, 2021 @ 02:58 AM

    The role of the media is justified for the modes for the candidates. Paths of the field and link samedayessay.com are inquired for the sows. Skills are matched for the argument for the mid of the offered count for the turns for humans.

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

Pages