How to automate Android native app using Leapwork on real Android Device?
How to automate Android native app using Leapwork on real Android Device?
Introduction
Leapwork's 2022.2.700 release provides 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, you can now run test case scenarios on actual physical devices.
We will now have a look at a use case scenario where we will try to send a test email through the Outlook application provided in almost every android phone.
Minimum Requirements
- 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.
- Lastly, before we can actually run our test cases, we would need to integrate our android devices with Leapwork. Click here for the detailed steps.
Apart from the above-mentioned 3 requirements, make sure you have your android phone connected to your local machine via data cable. Also, make sure to unlock your device prior to recording your test case.
Now that we are ready with all the must-haves, we can proceed with our use case. The steps we would be following here are the same as the ones you perform while you operate your phone physically.
Starting the Recorder
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 your mobile screen 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.
Opening the App Drawer
Now that we are able to see our screen we perform different actions on it. To start with, lets say to open the app drawer, we need to perform a swipe action on the home screen.
To perform a swipe action, left-click on the bottom of the screen, hold it and drag upwards. Once you release your mouse button you will be able to see options corresponding to the best-suited block for your action.
Select "Mobile Drawing Action", Click on Apply, and voila! your action is registered. You will also be able to see the swipe being performed on your physical device connected.
Starting the Outlook Application
After we have our app drawer open, we can type the name of the application in the search bar available. To be able to type in the search bar, we will have to tap on it first. We will again use the "Mobile Action" tap followed by "Set Mobile Text" to enter the name of the application.
We can now see our application in the app drawer. Again we will use the tap mobile action to open outlook.
Composing and Sending the Email
Once the application is opened on your device, you can perform the taps, swipes, and type(s) in a similar manner to send a test email. Below are some screenshots attached regarding our use case.
Use the combination of Mobile Actions and Set Mobile Text to fill up the values in the application (To, Subject and Body).
Once you are done filling in the details, you can press the send button by again using the tap Mobile Action.
Saving the Steps
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.
We have our flow created in less than 5 minutes, which can send email to anyone based on the address we provide in the Set Mobile Text block. You can also use a data-driven approach if you want to send an email to a large group by adding the "Read Excel" block with the method set to Iterate.
If you have any questions, please reach out to our Priority Support team.