Use Capybara-webkit (instead of Selenium) when Cucumber starts through Autotest?

I usually use Selenium with Firefox when manually running tests on a cucumber. But when I launch Autotest, I would like them to start using Capybara-webkit, because otherwise Firefox always skips to the forefront, and this is very annoying.

So how can this be achieved? I think I should install

Capybara.javascript_driver = :webkit 

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

Another option is to say that Firefox will start in the background, but how can this be achieved?

Here are some possible workarounds: use chrome! It seems to start in the background, so it does not interrupt your workflow. See http://collectiveidea.com/blog/archives/2011/09/27/use-chrome-with-cucumber-capybara/ .

Thanks a lot! Josh

+4
source share
1 answer

If you run this as part of a Rails project, I would recommend creating a new test group, one for the local one (i.e :test ) and one for the autotest (i.e :autotest ).

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

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

It is assumed that you are using Rails 3. If you are not using Rails 3 yet, I think you can just use RAILS_ENV to get the current environment name.

Once this is installed, simply modify Autotest to use the environment :autotest .

+1
source

All Articles