With Capybara, how can I tell whether the driver currently being used supports JavaScript?

capybara, cucumber, ruby-on-rails

Solution

In case anyone's interested, I took a look at the documentation for Capybara and found another possible solution:

if Capybara.current_driver == Capybara.javascript_driver
  # Supports JavaScript
else
  # Doesn't support JavaScript
end

Problem

In my Rails application, I have a set of cucumber acceptance tests that test various pages of my application. With cucumber, tagging a specific test (scenario) with `@javascript` causes that scenario to run using a JavaScript driver instead of a simpler driver that does not support JavaScript. Is there an easy way for my tests to determine whether they are currently being run with a driver that supports JavaScript or one that doesn't? I want this so that I can make my tests behave slightly differently if they are being run with JavaScript enabled.

Original source

Related problems