How to automate Android native app using Leapwork on Android simulator?
How to automate Android native app using Leapwork on Android simulator?
Introduction
Leapwork's 2022.2.700 release provides users with the ability to automate native mobile apps (both on IOS and on Android). With the help of an Appium server set up on the machine, users can now run their test case scenarios on their actual physical devices as well as the Android simulators.
In this article, we will take a look at how to create a virtual device on the local machine using Android Studio. We will also try to create an automation flow that will navigate to the Leapwork official website on the virtual device created.
But before that, below are some requirements in order to get our devices ready for automation:
- We need an Appium Server up and running on our local machine where we want to set up mobile automation. Click here for the steps.
- We would also need to set up an Android Native Environment before we set up the Appium Server. Click here to know how to set up the environment.
With the above two requirements in place, we can now proceed with the steps.
Step 1: Creating a virtual device in Android Studio.
Open the Android Studio installed on your local machine. Under the " More Actions" section select " Virtual Device Manager".
Choose any device from the given list of devices ( We will be using Pixel XL in this case) and click Next.
Once you click on next, you will get a prompt to download a system image corresponding to the android version you want to create a simulator for. ( In this case, we chose the android version R and downloaded the system image.)
Click on Next after you select the system image.
The last part of creating the device would be to verify the configurations and click on Finish.
You will now be able to see your device in the device manager window.
Click on the Play button corresponding to your newly created device and you will be able to see the virtual device running.
Step 2: Setting up the configuration for the Virtual Android Device.
- Please refer to the steps mentioned in this article to set up the configuration.
Step 3: Creating the flow.
Select the configuration from the dropdown present in Leapwork studio above the canvas.
Create a flow and right-click on the canvas. Click on Add building block and select " Start Mobile Recorder".
Once you start the recorder, you will be able to see the screen of the device you have just created, projected on your local machine and your cursor will turn into a square box just like it happens when we create any other flow. As you hover over the mobile screen you will see that Leapwork recorder is highlighting the objects present on the screen.
At the home screen itself, you will be able to see the google search bar on the top.
Move your cursor to the search box and perform a left click. Upon clicking, you will be presented with the list of building blocks in the order best suited for the element (The search box in this case).
Click on the "Mobile Action" building block, select the action as " Tap" and click on " Apply". The keyboard will pop up on your virtual device.
In the same way, perform a left click again on the search bar and this time, select the " Set Mobile Text" building block. Type in Leapwork and check the checkbox " Press Enter". Once you click on Apply you will see a search action being performed on the virtual device.
In the same way, using the same mobile actions, tap on the first search result and you will be directed to Leapwork's official website. You can then use the block " Get Mobile Text" to pick up any text from the website.
The last step would be to stop the recorder by hovering over the bottom left corner of the screen and clicking on the tick mark to save the recording.
Upon clicking on the save and close recorder button you will be able to see your flow automatically created in Leapwork studio.
There we have it, our flow created in Leapwork for the virtual device that was created in the android studio in the same way, we can automate any other application that we have on our virtual device.
If you have any questions, please reach out to our Priority Support team.