This is a guest blog post by Dave Haeffner, the founder and Captain of Arrgyle (a boutique QA consultancy), and the co-organizer of the DC Selenium Meetup.
Too often teams know what they want to accomplish with Selenium automation but get roadblocked by the infrastructure necessary before they can create their first script. Element 34 took this problem head on and created Saunter, an open source test automation framework that removes those roadblocks and says, ‘Here, do it like this’.
Money Where Our Mouth Is
With so many tools to choose from, and different ways to approach automated testing, we think Saunter goes about it the right way. So much, in fact, that we just ported it to Ruby (after adding a little bit of our own flair, of course).
Introducing ChemistryKit – a simple and opinionated open source web testing framework for Selenium WebDriver that follows convention over configuration. It’s wired ready for your Continuous Integration server and integrates with Sauce Labs for cross-browser execution in the cloud. Borrowed from Saunter, built in Ruby.
Hop In
Assuming you’re running a current version of Ruby (e.g. 1.9.3), it’s easy to get started. A simple `gem install chemistrykit` will do the trick. Don’t worry about finding a place to stuff it into your existing project, it can live in its own repository.
ChemistryKit is executed from the command line and is quite similar to Ruby on Rails. `ckit` for ChemistryKit is a lot like `rails` for Ruby on Rails.
Let’s take a tour
Executing `ckit` will display the available commands with some description:
Let’s generate an example test framework and call it something clever like… ‘example_test_framework’. This is done with `ckit new example_test_framework`
This generates the base file and folder structure you need to get started.
Put `cd` into the directory and get ready to generate some page objects and test scripts (known colloquially as ‘formulas’ and ‘beakers’). Generating a formula will generate both a formula and a beaker. But for this post, we’re just going to demonstrate a quick hello world example with a beaker.
A Simple Example
`ckit generate beaker ohai`
The beakers are written using RSpec and generated with a predefined tag. This is the default tag that is executed if none are provided on execution.
Here is a rudimentary example of accessing the browser object that is instantiated by ChemistryKit on execution (e.g. @driver) and using it to load Google.com:
Additionally, you can wrap your test steps in it/do blocks (with descriptor text), like so:
Kicking The Tires
For a quick sanity check, ChemistryKit is wired to run locally out of the box with Firefox. So once you have a test written, just run `ckit brew` to run your test suite on your local machine. You should see Firefox appear and load Google.com.
When it’s done, you should see something like this in your terminal:
Drive It To The Cloud
Best of all, connecting ChemistryKit to Sauce Labs is as easy as 1, 2, 3.
Step 1
Open _config/chemistrykit.yaml and set ‘run_locally’ to false, and ‘ondemand’ to true.
Step 2
In the _config directory, rename saucelabs.yaml.example to saucelabs.yaml.
Step 3
Add your Sauce Labs username and key to _config/saucelabs.yaml.
Now any time you run `ckit brew` your tests will execute in Sauce Labs under your account.
Are We There Yet?
Now you’re ready to add your newly created test framework into your version control system, wire it up to your CI, write some more beakers, and start getting quick feedback. Bravo!
Check out the getting started guide on the GitHub project page for more info. And for ChemistryKit related news, updates, and examples, be sure to keep an eye on Arrgyle.com.
–
Dave Haeffner is a man on a mission — to help people achieve their potential through effective technology use. He has spent the last 4 years working in the Quality Assurance space, helping various companies achieve better software quality with less effort. This is the current focus of his company (Arrgyle), which emphasizes the use of sound strategy, simple process, and open source tooling.
Dave is also the co-organizer of the DC Selenium Meetup, has spoken at various Agile conferences, and holds a Master of Science in the Management of IT from the University of Virginia.








[...] Introducing ChemistryKit — a Ruby version of Saunter is another self-serving link. [...]