Randomized testing with Selenium - Click Monkey

This post is a long time coming.

Introducing Click Monkey

A few months ago while I was down with a man cold. I started experimenting with sending randomized input to a web browser.

The goal was to create a standalone solution (or tool) to click random buttons and links in a webpage, and fill out forms with randomized input. Then have that tool report broken links or errors.

My last two blog posts were a result of my work to reach the "standalone" tool for controlling the browser.

  1. Controlling a browser through Node.js
  2. Detecting broken links for Selenium and webdriver on Node.js

The result is Click Monkey a npm commandline tool to do randomized testing of a webpage using a specified browser and Selenium.

Current features

  • File based configurations so you can run with different settings for different sites
  • A start up script, to handle login scenarios.
  • A fence to make sure the monkey does not leave the website you want to test, or to isolate it into a specific part of the website
  • Randomized "nice monkey" form inputs
  • Randomized clicking on page elements that usually imply interaction (div, button, a, img)
  • A simple broken link detection system, and server error notifications
  • Runs with webdriver.io which allows you to run the monkey with an array of different browsers

First experience

I've run Click Monkey on different websites I've helped develop. In it's current version Click Monkey will point out bad input validation and broken links.

The input Click Monkey generates right now tries to "play nice" with the how it perceives the website it interacts with. So the input should usually be accepted. Specifically for SQL backend's Click Monkey will show where the page can break due to input lengths.

Currently Click Monkey wont show you JavaScript errors, and it will not show you exactly what went wrong on the server side. Therefor I would recommend running Click Monkey with monitoring setup on the website it's running on, to capture both client-side and server-side errors with more details.

Background

I've had the idea in my head for a few years now.

During the Android Only conference in Stockholm in 2010, Erik Hellman presented how Sony Ericsson at the time implemented Android on phones.

He briefly mentioned that they used to test their phone using random input. (I think it was with the old keypad phones).

Before a phone enters the market it's been subjected to random input for a week or two, and if the phone hangs during that period then it doesn't pass the quality test for release.

This idea stuck, and it's been popping up in my head occasionally.

Netflix has since started introducing the concept of Chaos Monkeys in their production environment, as a way to ensure that engineers have reliability in mind when they design their solutions.

It felt good to finally be able to pour the idea out into something that actually does stuff. :)