Python Automation

Automating Android Apps

When we think about process automation, we immediately think about Desktop and Web. This happens because the vast majority of processes to be automated are available through web pages or are in applications that run on more common and consolidated operational systems such as Windows.

With digitalization and the growing importance of mobile and portable solutions, we have the emergence of several applications for mobile devices, especially in Android environments, and the possibility of automating mobile environments becomes increasingly necessary.

Automation in Android Environments

Currently, some alternatives used for automation in Android environments focus on automated tests, such as Selendroid and Appium.

Selendroid, despite its compatibility with different versions of Android, makes it possible to automate only one app at a time in addition to requiring special permissions in the application.

Appium, the most used framework for mobile automations, requires the configuration of an HTTP server as well as the usage of a UIAutomator driver to translate the automation commands. Moreover, Appium does not support older versions of Android making it necessary to use other tools to automate legacy versions.

Using the BotCity framework makes it possible to build complete automations of applications and processes on an Android system, quickly and in a very simplified way, similar to how it’s done in Desktop applications, mimicking the experience of a human user.

Accessing Android Environments

As an alternative to accessing an Android system, we can use tools that mirror the screen of a given device, such as Team Viewer. Or tools that emulate a complete Android system, such as Blue Stacks or Android Emulator, the emulator used in the Android Studio IDE.

Team Viewer

TeamViewer uses an Android app and a Desktop app that connects to the device through an ID provided by the app. The device screen is mirrored and it can be accessed through the Desktop.

Android Emulator

The Android Emulator simulates devices on your computer, enabling you to access and test different devices and applications without having a physical device.

BlueStacks

Similarly to Android Emulator, BlueStacks is a simulator that emulates an Android system without the mobile device. Just installing the emulator gives you access to a complete environment with no need for specific configurations.

Emulated device home screen

This way, using a tool that provides access to an Android environment and leveraging the BotCity Desktop Framework we can automate any Android application.

In this article we will use BlueStacks to build a basic example and demonstrate how the Desktop Bot works to automate an Android application.

A Practical Example

Prerequisites

For this example, you will need Python 3.7 or newer as well as the Blue Stacks emulator, which you can download using this link.

Setup

After downloading, install the Blue Stacks emulator. The installation does not require specific configurations, just follow the steps in the installer and, at the end, the environment will be ready for use.

Note that you can adjust the display settings as you see fit. For this example the default Blue Stacks settings are being used.

BlueStacks settings options

In this example, we will automate the process of filling out a form using the Jotform application. For that we will get the application from the Play Store and create the example form using the Information Request template.

Install Jotform app

With everything installed and the environment already configured, let’s create a new Python project of the Desktop Bot type using the project template through the CookieCutter command. You can find information on how to create a new project at this link.

Desktop Bot project template

Source Code

The code we will use in our example basically finds the form fields and fills them with the data.

We won’t be diving into the code details for this example but you can see how it looks like on the snippet below.

Source code example

You can download the code for this example clicking here and visiting the BotRepository.

Complete Execution

Conclusion

In this article, we covered strategies to develop automations in Android systems and the existing alternatives to access and configure this type of environment. A simple demonstration showed that the BotCity framework is also capable of operating on Android systems with ease. In a few steps you can access the environment and automate basically any application or process in the same way as for Desktop applications. This becomes a great alternative if an application or a certain process can only be accessed via an Android device.

Software Developer - BotCity

Comments

  1. Seria interessante se tivesse o link do repositório com o codigo fonte disponível…ou até mesmo em comentário aqui em baixo mesmo.

Leave a Reply

%d bloggers like this: