Coding Is Like Cooking

A blog by Emily Bache

Domain Specific Languages for Selenium tests

by | Aug 17, 2009 | Coding Skills, Uncategorized | 2 comments

I’ve been doing some work lately creating automated functional test suites using Selenium RC to simulate user interaction with a web GUI. I discovered quickly that the tests you record directly from selenium are rather brittle, and hard to read. In order to make the tests more robust and readable, I have been extracting reusable chunks of script that make sense from the user perspective, into separate methods. For example when testing a page for registering a new provider, you might have a ProviderPage domain class, with method “createNewProvider”. This method encapsulates all the selenium calls that interact with the page, and lets your test be written in terms of the domain.

I just saw this article from Patrick Wilson Welsh basically saying the same thing, only his DSL has three layers of indirection instead of just two. As well as encapsulating page operations in a Page class, he encapsulates operations on widgets within a page. I hadn’t thought of doing that. It makes the code in the Page class more readable. I might try that, and see if it improves my code.

Hi – I´m Emily!

I am an independent consultant with Bache Consulting and chair of the Samman Technical Coaching Society.  As a technical coach I work with software development organizations who want to get better at the technical practices needed to be agile, including Test-Driven Development, Refactoring and Incremental Design. I live in Gothenburg, Sweden, although I am originally from the UK. I’ve written two books: “Technical Agile Coaching with the Samman method” and  “The Coding Dojo Handbook”. I teach for both O’Reilly and  Pluralsight. I’m married to Geoff Bache, creator of TextTest. I am also on Mastodon as emilybache@sw-development-is.social.

If you’d like to know a bit more about me, my work, and the talks and workshops I offer, please visit my main website: EmilyBache.com. There, you’ll find information about my background, upcoming events, and the services I provide as a technical coach and consultant. It’s a good place to start if you’re curious about how I can support your team in improving coding skills and agile practices.

Blog categories