Automate browser with Imacros

Published April 28, 2017

Browser Automation is a wonderful thing, yet not too popular with non-programmers. Honestly, I don’t get why. There are many tools available – applications, browser addons and extensions, to ease repetitive daily tasks, whether it is business expert opening a set of tabs during specific meetings, tester going through acceptance test routine, or product owner trying to verify whether product still works as expected after the release. It is all nothing but input, output and few clicks in the browser, so it can be easily automated.

To showcase browser automation I have selected Imacros extension and Moz.com website. Imacros extension, because it is easy to use, and it supports action recording. Moz.com because they are assholes. Hence I created this script, and now will be happy to share this approach as an example of what can be achieved with few browser extensions and will to automate.

Automation Setup

Stack I used is very basic, allows to do this in-browser without programming skills. The setup is:

Chrome Browser, Firefox will do too

Imacros browser extension to automate clicks and data scraping – links for Google Chrome, Firefox. With this extension a lot of great things can be automated, what I will showcase is just the tip of the iceberg.

Extra for this use case – Anticaptcha extension to solve Google Re-Captcha – links for Google Chrome, Firefox. This comes with 5 free runs, afterwards costs 10$ for approx. 4600 captcha solves. Custom solution can also be built, but not easily – here’s a PDF with theory. If you know an implementation for this + new changes Google made, with success rate above 70%, ping me, please.

Automation flow

What the Imacros script below is instructing the browser to do:

Open a temporary email site, capture email address

Open Moz registration page

Fill in unique username and password, and above email

Wait for anti-captcha to solve, register

Open email, click on account activation link

Open Moz site API section

Wait for anti-captcha to solve, generate credentials,

Capture credentials, pass them to external API via GET parameters and save in DB

Log out from Moz, delete the temp email

Here’s a quick demo of below script executed through Chrome’s Imacros extension, it is 30 sec representation of a 4 min process:

GIF

Macro script

The workflow I used to generate this macro script is pretty straight forward. First used record mode and manually clicked through the flow. Then replaced my email provider with a temporary one. Then replaced copy-paste actions with variable extraction and set. Then found a solution for anti-captcha and added wait times to make sure it runs smooth every time. Finally added delete email and log out functionality to enable looping of the macro.

With Imacros you can record mouse clicks, inputs, and then replay them; add variables, extract data to .csv, use .csv as data inputs, and so on. It’s not perfect, but does the job pretty well and consistently. I hope this inspires someone to get this or similar browser extension, record daily clicks and save a lot of time. Cheers! 🙂