Testing Websites with Webdriver, WebPageTest and Node.js

Using node.js as an automated test engine

I'm using node.js rather than a dedicated testing suite to perform functional web testing with webdriver-sync and performance testing with webpagetest.

Why javascript?

There is nothing here that couldn't be (or hasn't been) done in other languages, but I have a working familiarity with javascript, so that is my language of choice.

Why node.js?

There will also be precious little here that plays to node's conventional strengths, such as http control and asynchronous program flow. Asynchronous is fine when you are responding to events and unknown amounts of traffic, but for testing where you want to control the flow of events and reach predictable results, it is a PITA. With that in mind, I'm using a synchronous version of the webdriver client, plus synchronous versions of base methods, to avoid the pain of dealing with nested callbacks and promises.

I had developed a workable interface from TestComplete to webdriver using the JSON protocol but TestComplete's version of Jscript (from IE5, would you believe?) and clunky editor left me wanting something more flexible. It took a bit of setting up but using Sublime Text to write scripts, executing them cross-browser and cross-OS with modern js in node and debugging them remotely with node-inspector suits me fine.

Which framework?

I don't use frameworks.

They all seem too wordy when I may need to be generating 50 tests a day. All of our tasks and bugs are documented and tracked in JIRA, so all of my tests refer back to JIRA issues. Why do the same work twice?


We'll start with setting up webdriver-sync, running tests on multiple OSes and mobile devices, then developing a DSL to produce readable, modular tests.

After that, it's handling uploads and downloads, having a look at the browser logs, an introduction to webpagetest, and finally running everything from Jenkins.

  1. Set up webdriver-sync
  2. Using multiple OSes and devices
  3. Readable test scripts
  4. Modular test scripts
  5. Uploads and Downloads
  6. Accessing browser logs
  7. Webpagetest for performance testing
  8. Continuous integration with Jenkins

And Finally

Some node.js tips and tricks that come in handy for testing