4

I normally use Selenium with Firefox when manually running my Cucumber tests. But when I have Autotest run, I'd like them to be run using Capybara-webkit because otherwise Firefox always jumps to the foreground, and this is very annoying.

So how could this be achieved? I guess I have to set

Capybara.javascript_driver = :webkit

in the env.rb file depending on whether the test is run by Autotest or not, but how to distinguish?

Another option would be to tell Firefox to start in the background, but how can this be achieved?

Here's some possible workaround: use chrome! This one seems to start in the background, so it won't interrupt your workflow. See http://collectiveidea.com/blog/archives/2011/09/27/use-chrome-with-cucumber-capybara/.

Thanks a lot! Josh

Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152

1 Answers1

1

If you are running this as part of a Rails project I would recommend you create a new test group, one for running locally (i.e. :test) and one for running with Autotest (i.e. :autotest).

In your env.rb file you can then do something like the following:

if Rails.env.autotest?
  Capybara.javascript_driver = :webkit
else
  Capybara.javascript_driver = :selenium
end

That assumes you're running Rails 3. If you are not yet running Rails 3 I think you can just use RAILS_ENV to get the current environment name.

Once that is set just change Autotest to use the :autotest environment.

mdgreenfield
  • 176
  • 1
  • 2