Having problems connecting to the default webkit server

801 views
Skip to first unread message

Andrew Beckwith

unread,
Nov 8, 2012, 2:48:01 PM11/8/12
to capybar...@googlegroups.com
I am pretty sure I have some kind of gem conflict, because I can get this working on a sample project using the same versions of my system's gems.

Here is the error output:

  @javascript
  Scenario: Activate listing                                                                                                  # features/create_whitelist.feature:15
2012-11-08 13:39:35.060 webkit_server[21048:307] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
 >> Visit
 >> 1
 >> 23
 << failure
 << 43
 << Unable to load URL: http://127.0.0.1:62354/
    Given I have successfully logged in as an operator                                                                        # features/step_definitions/base_steps.rb:1
      Unable to load URL: http://127.0.0.1:62354/ (Capybara::Driver::Webkit::WebkitInvalidResponseError)
      ./features/step_definitions/base_steps.rb:2:in `/^I have successfully logged in as an ([^"]*)$/'
      features/create_whitelist.feature:16:in `Given I have successfully logged in as an operator'
    When I navigate to the Listings Preview Activate page                                                                     # features/step_definitions/update_listings_steps.rb:37
    And I press Activate                                                                                                      # features/step_definitions/base_steps.rb:9
    Then I should see the newly uploaded SKUs in PENDING ACTIVATE status                                                      # features/step_definitions/update_listings_steps.rb:53
 >> Reset
 >> 0
 << failure
 << 43
 << Unable to load URL: http://127.0.0.1:62354/
      Unable to load URL: http://127.0.0.1:62354/ (Capybara::Driver::Webkit::WebkitInvalidResponseError)
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-webkit-0.12.1/lib/capybara/driver/webkit/browser.rb:138:in `check'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-webkit-0.12.1/lib/capybara/driver/webkit/browser.rb:87:in `command'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-webkit-0.12.1/lib/capybara/driver/webkit/browser.rb:22:in `reset!'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-webkit-0.12.1/lib/capybara/driver/webkit.rb:108:in `reset!'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-1.1.3/lib/capybara/session.rb:70:in `reset!'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-1.1.3/lib/capybara/dsl.rb:87:in `block in reset_sessions!'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-1.1.3/lib/capybara/dsl.rb:87:in `each'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-1.1.3/lib/capybara/dsl.rb:87:in `reset_sessions!'
      /Users/a936040/.rvm/gems/ruby-1.9.3-p194@mercury/gems/capybara-1.1.3/lib/capybara/cucumber.rb:10:in `After'

Failing Scenarios:
cucumber features/create_whitelist.feature:6 # Scenario: Upload whitelist
cucumber features/create_whitelist.feature:15 # Scenario: Activate listing

2 scenarios (2 failed)
13 steps (2 failed, 11 skipped)
0m4.404s

Here is my Gemfile:


ruby '1.9.3'

gem 'rails', '3.2.8'
gem 'bby_capi', :path=>'gems/bby_capi/'
gem 'queue_classic', git: 'git://github.com/ryandotsmith/queue_classic.git'
gem 'clockwork', require: false
gem 'haml'
gem 'pg'
gem 'less-rails-bootstrap'
gem 'inherited_resources'
gem 'cancan'
gem 'faraday', '~> 0.8.1'
gem "faraday_middleware", "~> 0.8.6"
gem "multi_xml", "~> 0.4.2"
gem "ox", "~> 1.5.4"
gem "gyoku", "~> 0.4.4"
gem 'devise', "~> 2.0.4"
gem 'devise_security_extension', git: 'git://github.com/bustoutsolutions/devise_security_extension.git'
gem 'simple_form'
gem 'thin'
gem 'highline'
gem 'exceptional'
gem 'thor'
gem 'colorize'
gem 'rubyzip'
gem 'heroku-api'
gem 'awesome_print'
gem "htmlentities", "~> 4.3.1"
gem 'paperclip', git: 'git://github.com/patshaughnessy/paperclip.git'
gem 'newrelic_rpm'
gem "SystemTimer", :require => "system_timer", :platforms => :ruby_18
gem "rack-timeout"

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server

group :development, :test do
  gem "debugger"
  #gem 'ruby-debug19', :require => 'ruby-debug'
  gem "heroku"
  gem 'unicorn'
  gem 'foreman'
  gem 'kumade'
  gem 'quiet_assets'
  gem 'spin'
  gem 'kicker'
  gem 'pry'
end

group :test do
  gem "faker"
  gem 'shoulda', :require => false
  gem 'webmock', :require => false
  gem 'nori'
  gem 'factory_girl'
  gem 'autotest-standalone'
  gem 'autotest-rails-pure'
  gem 'autotest-growl'
  gem 'autotest-fsevent'
  gem 'vcr'
  gem 'database_cleaner'
  gem 'rspec', :require => false
  gem 'capybara'
  gem 'capybara-webkit'
  gem 'cucumber-rails', :require => false

  # mocha must be required last
  gem "mocha", :require => false
end

You may wonder why all the Shoulda/TestUnit/Rspec/etc - legacy unit and functional tests are in shoulda/testunit - new are in rspec, cucumber/capybara etc...

I am using the default env.rb generated by rails generate cucumber:install --capybara, with the addition of Capybara.javascript_driver = :webkit_debug

I have essentially stripped the steps down to nothing, and the Given just has a visit '/' in it.

Does anything jump out to anyone here? Please let me know if more info is required, gem versions, etc... This is Rails 3/Ruby 1.9.

Joe Ferris

unread,
Nov 8, 2012, 2:50:07 PM11/8/12
to capybar...@googlegroups.com
Hey Andrew,

It's worth trying using the latest version on master rather than the latest release version, because a number of InvalidResponse errors have been fixed. Master also has better output for the webkit_debug driver.

-Joe

Andrew Beckwith

unread,
Nov 8, 2012, 3:01:38 PM11/8/12
to capybar...@googlegroups.com
I am going to give that a quick try and report back...

Andrew Beckwith

unread,
Nov 8, 2012, 3:04:32 PM11/8/12
to capybar...@googlegroups.com
You are right - the error message output is much better, but unfortunately for me, the error still persists:

  @javascript
  Scenario: Activate listing                                                                                                  # features/create_whitelist.feature:15
2012-11-08 14:02:39.641 webkit_server[23050:307] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
Finished "EnableLogging" with response "Success()" 
Wrote response true "" 
Received "Visit" 
Started "Visit" 
Load started 
"Visit" started page load 
Started request to "http://127.0.0.1:62530/
Finished "Visit" with response "Success()" 
Received 301 from "http://127.0.0.1:62530/
0 requests remaining 
Started request to "https://127.0.0.1:62530/
Received 0 from "https://127.0.0.1:62530/
0 requests remaining 
Page finished with false 
Load finished 
Page load from command finished 
Wrote response false "Unable to load URL: http://127.0.0.1:62530/ because of error loading https://127.0.0.1:62530/: Connection closed" 
    Given I have successfully logged in as an operator                                                                        # features/step_definitions/base_steps.rb:1
      Unable to load URL: http://127.0.0.1:62530/ because of error loading https://127.0.0.1:62530/: Connection closed (Capybara::Webkit::InvalidResponseError)
      ./features/step_definitions/base_steps.rb:2:in `/^I have successfully logged in as an ([^"]*)$/'
      features/create_whitelist.feature:16:in `Given I have successfully logged in as an operator'
    And I have uploaded the whitelist skus (/Users/a936040/Workspace/mercury/features/support/data/listing_and_tax_codes.csv) # features/step_definitions/update_listings_steps.rb:5
    And I have uploaded tax code data (/Users/a936040/Workspace/mercury/features/support/data/listing_and_tax_codes.csv)      # features/step_definitions/update_listings_steps.rb:12
    And I have uploaded inventory data (/Users/a936040/Workspace/mercury/features/support/data/inventory.csv)                 # features/step_definitions/update_listings_steps.rb:19
    When I navigate to the Listings Preview Activate page                                                                     # features/step_definitions/update_listings_steps.rb:37
    And I press Activate                                                                                                      # features/step_definitions/base_steps.rb:9
    Then I should see the newly uploaded SKUs in PENDING ACTIVATE status                                                      # features/step_definitions/update_listings_steps.rb:53
Received "Reset" 
Started "Reset" 
Finished "Reset" with response "Success()" 
Wrote response true "" 

Joe Ferris

unread,
Nov 8, 2012, 3:06:54 PM11/8/12
to capybar...@googlegroups.com
It looks like your root URL is attempting to redirect to itself. I haven't tried that before, but QtWebKit may refuse to accept a recursive redirect.

Andrew Beckwith

unread,
Nov 8, 2012, 3:21:14 PM11/8/12
to capybar...@googlegroups.com
Following your theory, I opened the developer tools Network pane, and watched - and you are right, it was doing a redirect to itself before forwarding on to /users/sign_in

So I tried cutting to the chase: visit '/users/sign_in'

  Scenario: Activate listing                                                                                                  # features/create_whitelist.feature:15
2012-11-08 14:15:49.124 webkit_server[23510:307] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
Finished "EnableLogging" with response "Success()" 
Wrote response true "" 
Received "Visit" 
Started "Visit" 
Load started 
"Visit" started page load 
Finished "Visit" with response "Success()" 
0 requests remaining 
0 requests remaining 
Page finished with false 
Load finished 
Page load from command finished 
Wrote response false "Unable to load URL: http://127.0.0.1:63656/users/sign_in because of error loading https://127.0.0.1:63656/users/sign_in: Connection closed" 
    Given I have successfully logged in as an operator                                                                        # features/step_definitions/base_steps.rb:1
      Unable to load URL: http://127.0.0.1:63656/users/sign_in because of error loading https://127.0.0.1:63656/users/sign_in: Connection closed (Capybara::Webkit::InvalidResponseError)
      ./features/step_definitions/base_steps.rb:2:in `/^I have successfully logged in as an ([^"]*)$/'
      features/create_whitelist.feature:16:in `Given I have successfully logged in as an operator'

Do you know why (or am I missing something) it is trying the SSL url? There obviously isn't one running... When I follow this in Chrome's dev tools, there is no redirect happening when I go direct to /users/sign_in

Joe Ferris

unread,
Nov 8, 2012, 3:31:35 PM11/8/12
to capybar...@googlegroups.com
Do you have it set up to redirect to the SSL version in production? It's possible that it's configured per-environment and you haven't disabled it for the test environment.

Andrew Beckwith

unread,
Nov 8, 2012, 3:31:45 PM11/8/12
to capybar...@googlegroups.com
is it just trying the SSL url because it gets a 301 from the non-SSL path?

Joe Ferris

unread,
Nov 8, 2012, 3:36:03 PM11/8/12
to capybar...@googlegroups.com
Redirecting to SSL isn't something that capybara or capybara-webkit does by default, so there must be some logic in your application to change protocols.

Andrew Beckwith

unread,
Nov 8, 2012, 3:54:46 PM11/8/12
to capybar...@googlegroups.com
In our config/environments/test.rb, we forgot to override the 'config.force_ssl = false' that was being set to true in the configuration/application.rb

Setting this allowed things to operate smoothly - thanks for you help pointing me in the right direction.

Anthony Cintron

unread,
Nov 14, 2012, 3:23:05 PM11/14/12
to capybar...@googlegroups.com
I to am having issues with getting a sign_in page to load. I am running rails 3.0.17. Which means config.force_ssl = false may not work for me. However, I am using ssl_required, and I am suppressing the switch to ssl on the application_controller level. I'm not sure the redirect is an ssl issue. I'm more concerned about 'www' being prepended to the request. Should that be the potential issue? 

Please see my output below:

Finished "EnableLogging" with response "Success()" 
Wrote response true "" 
Received "Visit" 
Started "Visit" 
Load started 
"Visit" started page load 
Finished "Visit" with response "Success()" 
else
{"SERVER_SOFTWARE"=>"thin 1.4.1 codename Chromeo", "SERVER_NAME"=>"127.0.0.1", "rack.input"=>#<StringIO:0x007fbe21641338>, "rack.version"=>[1, 0], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/users/sign_in", "PATH_INFO"=>"/users/sign_in", "REQUEST_URI"=>"/users/sign_in", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; PPC Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) capybara-webkit Safari/534.34", "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "HTTP_CONNECTION"=>"Keep-Alive", "HTTP_ACCEPT_ENCODING"=>"gzip", "HTTP_ACCEPT_LANGUAGE"=>"en-US,*", "HTTP_HOST"=>"127.0.0.1:54790", "GATEWAY_INTERFACE"=>"CGI/1.2", "SERVER_PORT"=>"54790", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "rack.url_scheme"=>"http", "SCRIPT_NAME"=>"", "REMOTE_ADDR"=>"127.0.0.1", "async.callback"=>#<Method: Thin::Connection#post_process>, "async.close"=>#<EventMachine::DefaultDeferrable:0x007fbe2163f920>, "action_dispatch.parameter_filter"=>[:password, :password_confirmation], "action_dispatch.secret_token"=>"e3d48a43358c6881f63c20a0d341af12e385228ee09589614900d39e6e199412788e09c73f11ecadd2dbc7a3345cc28c8444caf819063bcc079017efb91c35cd", "action_dispatch.show_exceptions"=>true}
Started request to "http://www.0.1:54790/users/sign_in
1 requests remaining 
0 requests remaining 
Page finished with false 
Load finished 
Page load from command finished 
Wrote response false "Unable to load URL: http://127.0.0.1:54790/users/sign_in because of error loading http://www.0.1:54790/users/sign_in: Socket operation timed out" 

Joe Ferris

unread,
Nov 14, 2012, 3:26:10 PM11/14/12
to capybar...@googlegroups.com
It looks like your SSL redirect code is replacing parts of the domain, so that "127.0.0.1" becomes "www.0.1," which obviously won't work.

You can change your code to be configurable, so that it doesn't do this during integration tests, or you could set up a host alias for 127.0.0.1, such as www.yourapp.test. You can use /etc/hosts for this, but every machine will need to be setup with the alias to run tests.

-Joe
Message has been deleted
Message has been deleted

Anthony Cintron

unread,
Nov 14, 2012, 4:41:13 PM11/14/12
to capybar...@googlegroups.com
Apologies. I ended up fixing the bigger issue...

Unfortunately, a prior developer had the following code:

r301 /.*/,  Proc.new { |path, rack_env| puts "else";  puts rack_env.inspect; parts = rack_env['HTTP_HOST'].split('.'); "http://www.#{parts[-2]}.#{parts[-1]}#{path}" }, :if => Proc.new { |rack_env| !(rack_env['HTTP_HOST'] =~ /www\./i) }

Which I ended up removing for tests. Thanks for the helpful guidance!
Reply all
Reply to author
Forward
0 new messages