Been making a big effort of late speeding up our cucumber tests. We saw significant speed gains using capybara-webkit instead of selenium webdriver, but the problem is that capybara-webkit doesn't always work so well on some of our @javascript cucumber scenarios. In order to work around this problem for now, we default to the webkit driver for all of our @javascript scenarios and fallback to selenium in some cases by tagging @selenium.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
@javascript @selenium Scenario: I should be able to remove spaces from my spaces page Given I am a logged-in broker And I have 2 spaces And I am on my spaces page And I click remove for first space And I confirm popup Then I should see remove successfull message And The space should be removed from my spaces And The space should no longer be visible on my spaces page
@javascript Scenario: Share a space Given I am a broker And a space exists And I am logged in And I am on the space page And I follow "Share" And I fill in "Email Addresses" with "myfriend@test.com" And I press "Send" And a shared space should exist
|
In order to get this working, we defined @selenium tag hooks within the features/support/custom.rb (could be any file in the support directory).
1 2 3 4 5 6 7 8 9 10 11 12 13
|
def default_javascript_driver ENV['WEB_TEST_JS_DRIVER'].try(:to_sym) || :webkit end
Capybara.javascript_driver = default_javascript_driver
Before('@selenium') do Capybara.javascript_driver = :selenium end
After('@selenium') do Capybara.javascript_driver = default_javascript_driver end
|
Before each @selenium scenario, change to selenium. After the scenario, we change back to the previous driver.
This is a pretty cool idea!
ReplyDelete