I’ve lately moved from Cucumber to RSpec features, and have found the need to test some features that rely on javascript in order to function.
The Basics
This is very easy to do with capybara-webkit, you just need to add one line to your spec_helper
:
1
|
|
And a little magic flag on your RSpec example:
1 2 3 |
|
However, I have found myself in situations where, for a specific test, I want to use the selenium driver. The reasons can go from capybara-webkit not behaving like the real browser to, more commonly, me being on a debug mission and wanting to see it rendered on the browser.
Dynamic driver
To solve this problem I came up a solution that allows me to dynamically choose the driver I want for a given example.
I just added this snippet of code to my spec_helper
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
This allows me to use the default syntax:
1 2 3 |
|
or to choose selenium:
1 2 3 |
|