简体   繁体   中英

How to make cucumber-rails use watir-webdriver instead of Capybara

I have been searching for a simple answer to this for a few days and can't seem to find an one, on either stackoverflow.com or google. So, firstly, if this is answered elsewhere please point me in the correct direction.

So, I have a relatively new Rails 3 project using the cucumber-rails gem. I am relatively new to Rails but have experience in Ruby and other web frameworks such as Sinatra and Ramaze. My understanding is that out of the box, cucumber-rails uses Capybara for interacting with the web application and somehow does this without starting the rails server. It somehow interacts with rack to simulate the requests. Not sure if I have that entirely correct but I'm pretty sure it does not need a running rails server.

I am not a great fan of the Capybara DSL and I much prefer watir-webdriver which I have used in a few non rails projects (and non Ruby projects even). However, I have not been able to find anywhere to show me how to swap out Capybara for watir-webdriver.

So my questions are these:

Does the cucumber-rails gem have the ability to swap Capybara out for watir-webdriver?

If so, what is the best way to do this?

If not, does that mean I need to ditch cucumber-rails and just set cucumber with watir-webdriver up in my project manually?

Well, it doesn't look hopeful from the project description :

Rails Generators for Cucumber with special support for Capybara and DatabaseCleaner

And sure enough, it explicitly, unconditionally, loads Capybara here

I think that means that you're going to need to hook it up yourself.

Having said that, I don't think there's anything stopping you from installing the gem, running rails g cucumber:install , and then replacing the Capybara-specific bits in the files it produces.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM