On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
Limits of rack-test• “Dumb” web browser• Follows redirects• Rendering engine is Nokogiri• Fill out forms, click links• Handles 90% of the web• (but the other 10% is the shiny part)
Simple TestFeature: sign up for an account Scenario: sign up When I go to the home page And I ﬁll in the following: | Email | firstname.lastname@example.org | | Password | taters | And I press "Sign up" Then I should have an email of "email@example.com"1 scenario (1 passed)4 steps (4 passed)0m0.446s
Simple ChangeFeature: sign up for an account Scenario: sign up When I go to the home page And I ﬁll in the following: | Email | firstname.lastname@example.org | | Password | taters | And I press "Sign up" Then I should have an email of "email@example.com" And I should have an account name of "jferris"
Limits of Selenium• Slow, slow, slow• GUI browser adds a lot of cruft you don’t want that gets in the way• Browsers were designed to be clicked on and looked at, not controlled and queried
Slow• Boot up Firefox with fresh proﬁle• Set up Firefox with extension• Communicates over JSON REST API
But you need Qt• Download installer on OS X• Most Linux distros have a package
Caveats• capybara-webkit’s engine is still designed to build browsers, so there are some interactions we can’t get between• All tests are asynchronous (like with Selenium), so you still need Capybara’s retrying methods• capybara-webkit is still young, so things are ﬂakier than with Selenium
WebKits: how do they work? • capybara-webkit is built around QtWebKit • Headless browser listens for commands using a lightweight socket layer • Ruby driver implements the capybara API and communicates with the server
WebKit• Based on KHTML• Open source• Powers Safari, Chrome, and other browsers• Cross-platform, fast, standards-compliant
WebKit• WebKit is not a browser, or really even a browser engine• WebKit is a set of libraries for building browsers• WebKit is not packaged as a standalone library• There is no one WebKit
Qt• Powers the KDE desktop• Tools, extensions, and libraries for building GUI applications in C++• Provides a packaged wrapper around WebKit called QtWebKit
QtWebKit• Qt implementation of WebKit with nice API and documentation• Lots of injection points for building your own browser• We built a test harness instead
• capybara-webkit is open source• Please submit pull requests
Thank You Joe Ferris @joeferristhoughtbot/capybara- webkit