Capybara driver rack_test

Why is CircleCI using rack_test (whatever that is) as the capybara driver when I specified webkit?

I’m getting the following error message on CircleCI, but not locally.

Don't know how to resize browser window for Capybara driver rack_test

Which is coming from my custom module

module ResizeBrowserWindow
  def resize_browser_window(options = {})
    case Capybara.current_driver
    when :chrome
      Capybara.current_session.driver.browser.manage.window.resize_to(options[:width], options[:height])
    when :webkit
      Capybara.current_session.current_window.resize_to(options[:width], options[:height])
      raise "Don't know how to resize browser window for Capybara driver #{Capybara.current_driver}"

By default Capybara will use Rack::Test. This Ruby library interacts with your app from the Rack level, similar to an external user. It runs requests against your app, then provides the resulting HTML to Capybara and RSpec for examination.

Try below

window.resize_to(1024, 768) # width, height

Hope this helps.

Hmmm… your suggestion was not comprehensive enough. Do you mean…

Capybara.current_session.window.resize_to(options[:width], options[:height])


Yes , For Capybara.current_session.window.resize_to(options[:width], options[:height])

Try , window.resize_to(1024, 768) # width, height .

Now I’m getting
undefined method 'window' for #<Capybara::Session>

I think it works with firefox only , please refer this url

But… the whole topic here is webkit… I’m not interested in running firefox. My issue is that I specified webkit but CircleCI seems to have it’s own ideas about what to run.

Can you please tell me why you are not calling driver.browser.manage in below ?

when :webkit
Capybara.current_session.current_window.resize_to(options[:width], options[:height])

Last i would suggest, keep both the method same and give it one more try .

Sorry for the delay here.

We are not overriding your configuration in any way that would not be expected. Are you sure that none of the dependencies you specify in your Gemfile force the selection of rack_test as the default driver?

Are you sure that the information returned by Capybara.current_driver is accurate?

Could you please run the tests on CircleCI with RAILS_ENV and RACK_ENV set to development instead of test? Would be great if you did that manually through the SSH build to see if there is any change of the behaviour in this case. Thanks.

Hi Alexey, thanks for the suggestions.

Our environments are set up such that development takes place in development and testing in test. When our tests are run both locally and on CircleCI they’re run under the test environment. I don’t see a benefit to running them under development, plus I ensure test is the environment at the top of the spec_helper.rb file with ENV['RAILS_ENV'] = 'test' (I’ve had a situation where it was run in development for some reason and it blew away my db)

We’re using Capybara.javascript_driver = :webkit in our spec/support/capybara.rb file. When running locally, it is correctly identified as :webkit, but on CircleCI it is reporting rack_test as evident from the error reported from the ResizeBrowserWindow module.

(P.S. running in development on CircleCI requires I modify a bunch of files on the container)

Sorry for the confusion here—I just wanted to check if the behaviour differs between development and test, and now that the tests are running locally with RAILS_ENV = test, there is no need to check that.

Are you running the same versions of Capybara / capybara-webkit on CircleCI as the ones that are used locally? Which versions do you use on your dev machine?

Pretty basic setup here. I don’t see why CircleCI would be running a different version than locally, it’s all controlled by a Gemfile.lock which is generated via the Gemfile, below is the test excerpt.

group :test do
  # Generate test data for specs
  gem 'factory_girl_rails'

  # Code Climate test coverage integration from build server
  gem 'codeclimate-test-reporter', require: nil

  # Raises an error when you use a capybara finder and it times out. (Use a double negative, instead)
  gem 'capybara-slow_finder_errors'

  # See the coverage for tests
  gem 'simplecov'

  # keep environment loaded between test runs
  gem 'spring'
  gem 'spring-commands-rspec'

  # Generates fake data primarily for testing
  gem 'faker'

  gem 'capybara'
  gem 'capybara-webkit'
  gem 'selenium-webdriver'
  gem 'poltergeist'

  gem 'elabs_matchers',       '~> 0.0.7'
  gem 'launchy',              '~> 2.4.2'
  gem 'shoulda-matchers',     '~> 2.6.1'
  gem 'rspec-sidekiq'
  gem 'chromedriver-helper'