Exploring beyond Selenium? You’ve come to the right place.

I was motivated to explore alternative solutions for browser automation because tools like Selenium and even Katalon studio are very hard to setup and I wanted to have a REPL driven experience of interacting with the browser during development, languages like Java don’t provide that.

The goal of this project was to simply get started with a Clojure REPL driven based approach to browser automation and though there aren’t many articles or blogs on the internet about the same, I could grasp the basic concepts using the `tests` in the main `Github` repository for `Etaoin`.

Key Ideas and Learning Tools

  • Clojure: Clojure is a dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming.
  • WebDriver Protocol: WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.
  • Etaoin: Pure Clojure implementation of Webdriver protocol. Use that library to automate a browser, test your frontend behaviour, simulate human actions or whatever you want.
  • Cursive: The Clojure(Script) IDE that understands your code. Advanced structural editing, refactorings, VCS integration and much more, all out of the box.
  • Firefox Developer Edition: A developer focused build of Firefox, with the latest features, fast performance, and the development tools you need to build for the open web.
  • Browser Automation: Browser automation means you write a program that emulates what a human will do in a browser.

But first, let’s make sure we’ve set up everthing correctly.

For this I made a video, which goes into a bit more depth regarding setting up Clojure with IntelliJ Cursive for professional development

Browser Automation in Clojure

This walkthrough assumes that you’re using IntelliJ Cursive for clojure development, I think it’s one of the simplest ways to get started with clojure though there are other options like cider in spacemacs, chlorine in Atom and calva in VsCode.

  • To get started, simply opt for checkout from version control in IntelliJ.
  • Create the REPL configuration for a local clojure REPL.
  • Fill up the secrets.edn as per your system configuration.
  • Fire up the REPL and move to the core namespace and start evaluating the forms and in the end simply execute the main function.
  • Once the program runs, it’ll read the draftPost from the file system and type it within the Reddit message dialog and save a draft as well as a screen shot of the Reddit draft on the file system.

Learning strategy

Since I had some prior experience with automation tools, I basically relied on reading the tests in the main etaoin repository on Github. I think that it’s quite easy to get started with once the project is all setup correctly.

NOTE: The browser window size matters during the execution of etaoin programs and so I realized that once the code is develop it’s better to deploy on the headless mode.

Browser automation is a great way to create custom workflows, for example

  • For platforms which don’t offer programmatic access via an API
  • For automating certain repetitive tasks which rely on the User-Agent being a browser
  • For scraping and collecting data

Reflections on the experience

I think one of the biggest differences between an average engineer and an expert is the ability to read and comprehend the source of the libraries that we are using rather than just relying on treating them as a black box.

Conclusion and Next steps

As we were just getting our feet wet with the setup, getting to know the capabilities of etaoin and clojure REPL driven browswer automation, we took on only a simple task. However there are major applications of browser automation in regression testing during software development life cycles and in future we’ll be exploring how etaoin could be used in a more professional environment.

Image Credits: Wikipedia.com