Play Popcat like A Pro – Developer and Automation Tester Way

Popcat is really hot nowadays, at the time of writing, Malaysia is ranked #2 worldwide with 8.1 billion pops and 120.5k pops per seconds (PPS), Finland is ranked #3 with 5.4 billion pops and 425.7k PPS (crazily high). With the current speed, Malaysia will be winning over Taiwan who is currently ranked #1 with 13.5 billion pops, but with only 36.4k PPS, in a matter of time.

Being a software development house with more than 90 man strong, we are dealing with similar situations in daily basis. In this weekend, We are challenging ourselves by applying our professional software knowledge for development and automation testing in this real life scenario. Here’s the video on how it works if you are interested. Note that there are also non software way, such as using some small robots which are quite interesting too. Feel free to check it out.

We started with using an automation script obtained from Github. The script was working perfectly before we noticed there was a bot checking mechanism. Here is how it works:

  • It simulates a keyboard press event
  • Repeat it again and again using Javascript setInterval method

After that, we noticed our cats’ eyes become red color:

Then we noticed the eyes are red when the “bot” flag is set in cookie

Thanks to an Agmoian sharing a post from Facebook. We have learnt that the frontend code will:

  • Send the statistic to server every 30 seconds
  • If it is more than 800, then the frontend will set the “bot” flag in cookie to true
  • If the bot flag is true, then the stat won’t be sent to server

You can also unminified the minified Javascript code by using tools like https://unminify.com/

Before:

After:

The author, Tommy Wong has also written a workaround script, which works perfectly fine:

document.cookie=”bot= ”
const event = new KeyboardEvent(‘keydown’, { key: ‘a’, ctrlKey: true });
const timegap = 1 / (790 / (30 * 1000));
setInterval(() => {
document.dispatchEvent(event);
}, timegap);

Then the next challenge is how do we deploy this in mass scale, a few ideas come into our mind:

  • Using Azure Test Center to spawn multiple test devices to run automation script
  • Using Firebase Test Lab to run the app automatically in cloud
  • Using Phantom JS (headless browser) + Docker to scale it (Suggested by Ivan)
  • Using Selenium in AWS (Suggested by Jermaine)

However, after all above won’t work, as the public cloud has no Malaysia IP range. Also, the API is rated limited by IP, we cannot use the same Internet Connection, hence we are using multiple data plans and Wifi to bypass the bot checking.

With this, we have to do it more manually with our resources. We have bought plenty of test devices for COVID-19 Bluetooth Contact Tracing development last time. It’s time to bring them to the game. So, how do we run the Javascript in our mobile phones just like using Console in our Chrome?

The way for doing this is slightly different for desktop, Android and iOS.

For desktop:

  • Open Chrome – Developer Tools
  • Click Console and paste in the script above by Tommy will do

For Android:

  • You have to turn on “Developer Option” first

1 Go to “Settings”, then tap “About device” or “About phone”.
2 Scroll down, then tap “Build number” seven times.

  • Then, turn on USB debugging in “Developer Option”
  • On your development machine, open Chrome.
  • Go to chrome://inspect#devices.
  • Make sure that the Discover USB devices checkbox is enabled.
  • Then you can click “Inspect” on the web page. Refer here for more details.
  • Click Console and paste in the script above by Tommy will do

For iOS:

  • Go to Settings – Safari – Advanced – Allow Web Inspector
  • Go to Safari, Develop – and select your devices
  • You can then use the Console just like Chrome Debugger Console
  • Click Console and paste in the script above by Tommy will do

As simple as that, you can make your computer, iOS or Android phones to click automatically for you, when you are sleeping, eating or doing anything. Feel free to try it out.

Interested to have automation testing for your web or mobile application? Write to us at [email protected]