I was faced with a very long survey.
The online survey consists of 80+ questions with each question taking up to 5 mouse clicks.
My team is facing the reality of having to answer this survey multiple times.
So I stepped forward and wrote a script that can automate this process. And here’s how I wrote it.
The problem was that my team will have to answer this survey multiple times, and this activity is too time-consuming, not to mention taking the test, in our context, is mindless.
The POSSIBLE APPROACHES
I saw three possible approaches how I can automate this and solve the problem:
- Use Selenium IDE
- Write a Python script
- The DOM elements that I need to interact with do not have a unique identifier. Though I can find a way to bypass this, but that will make the code unnecessarily complex.
So I moved to try my hand at Selenium IDE. Then I found out that the survey doesn’t really like it (e.g. laggy, unoptimized DOM design)
Alas, what other option could there be? Could this be the perfect opportunity to try my hand at Python and sharpen my skills?
With a few reviews and a few Google searches, I wrote the Python script in a single sitting. Attached below is a screenshot of the entire source code:
This is how the script works: The application hijacks the mouse and automates the user behavior by automatically clicking on the survey buttons under configurable parameters (e.g. mouse speed, button coordinates, number of loops)
Below is the end result of my automation script:
And of-course I can configure it such that it executes at lightning speed.
And that’s how I saved company resources and client money. This gave me extra capacity to do creative work instead, while also allowing my team to focus on their development priorities instead of mindless tasks.
This tool was written only for my specific needs, and there are certainly a lot of room for improvement that I can explore, namely:
- Better fail safe mechanisms
- User-friendly customizations of parameters
- Application behavior customizations
With that said, I unintentionally knocked down yet another of my 2020 goals. Praise God!
PS: To the techy geeks and the aspirants, the source code is available here.