Q:

Comparison of capybara-webkit vs selenium-webdriver

I want to write test cases for my rails application. I have already written a lot of test cases in Rails built-in framework Minitest. 
Now I want to test javascript functionality of my web app. 
I came across these two tools
1: Selenium web-driver
2: Capybara-webkit
I am confused which one to use. I know few advantages and disadvantages of these two tools like

Capybara webkit is headless while selenium web-driver open a browser.
Capybara is faster than selenium.
Capybara cannot open any other application while selenium can interact            with third party apps like facebook and LinkedIn 

Can anyone tell me the comparison of these two tools for testing ?

A:

You're confusing a few things here.  Capybara is a testing framework/DSL, for Ruby, which can be used with any of the test runner frameworks (RSpec, Minitest, etc).  It can use a number a of different drivers to communicate with the web app being tested.  
The default driver is rack_test which doesn't support any JS and cannot connect to any addresses outside the app under test.  
A second driver option is selenium-webdriver which can control multiple different real browsers firefox/chrome/safari/etc. for testing, and can connect to any valid URL.  The downside of using selenium-webdriver as the driver is that it opens a real browser and is therefore usually slower with a larger memory footprint.
Another driver option is capybara-webkit which is headless and can also  connect to any valid URL.  It is generally faster than using selenium however as it is built on an old version of QtWebkit it doesn't support newer web standards (ES2015, etc) so at a minimum you need to make sure all JS is transpiled to ES5 maximum.
There is nothing to stop you using different drivers for different tests to get the benefits of speed for most tests and then use a real browser for tests that need things like WebRTC, etc.  The Capybara README details how to do that when using different test runners (RSpec, Minitest, etc)

