DEV Community

Michael Lopez
Michael Lopez

Posted on

How To Automate Native Apps On Android Device Using Appium?

The time individuals spend online steadily rises each year. Spending more time on mobile devices directly results from the rise in mobile device use. This rise in smartphone use may be attributed mainly to the variety of fun and practical applications available for download. Therefore, it is crucial that an app be both stable and fun to use. Suppose users encounter any problem with the software, whether a crash, a slowdown in performance, or an unintuitive UI, they will feel free to submit a bad review. In terms of the user base, Android is unrivaled. Therefore, mobile automated testing is essential to forestall unfavorable feedback and product failure.

What is Appium?

Appium is a free, open-source automated testing solution that works on several platforms. Since its inception, this tool has been dedicated to testing mobile applications developed for Android and iOS. It's put to work in automating test cases for both online and native apps. In addition, Appium has just stated that they would enable the testing of windows desktop programs, following up on an earlier upgrade.

Sauce Labs is responsible for creating and updating Appium. Distributed versions of Appium now stand at 1.12. When initially released, Appium was a node.js-based testing service that could be deployed through the command line. Appium Desktop is their most recent version, and it's a powerful, well-defined product with a simple UI.

Why should you choose Appium?

Appium is still the gold standard when it comes to testing apps automatically. Reasons for choosing Appium automation:
● In the background, this server does its thing.

● TestNG, a testing framework with more options, could be synced with it.

● Appium features an in-built UIAutomator that generates information logs and a rich reporting framework for analyzing test results and facilitating troubleshooting.

● It allows test code to be written in various languages (including Java, JavaScript, PHP, Ruby, Python, and C#).

● Using it, you may write once and run everywhere on several mobile operating systems.

The time and energy saved by this are substantial.
● QAs are given complete access to the back-end APIs and databases using the provided test code. This is useful for analyzing problems that originate in back-end services, such as APIs or databases.

● Appium for Android employs the same automation APIs across all platforms, so testers don’t need to change or recompile the app being tested. In addition, they don’t need access to the application’s source code.
● The same tests may be performed on several systems to increase coverage thanks to its cross-platform interoperability.

● It provides real-time test monitoring, which strengthens test execution.

● Appium enables the concurrent execution of test automation scripts on several Android or iOS sessions via UIAutomator, UIAutomator, or Xcode9. As a result, we can guarantee scalability and speed up the testing process.

Steps To Automate A Native App

Appium android automated testing needs the user to declare the required capabilities before they can run. Including them in appium.txt files or the test code is possible. Client-requested features are often represented via a JSON object (a collection of keys and values) sent to the server. By configuring a browser session with specific permissions and settings, testers may have more influence on the server during automated Appium testing.

Get Details of Mobile Device

  • Connect the real-time mobile device through USB or establish a virtual machine inside the system. You may construct a device emulator using AVD manager from the Android SDK package or GenyMotion software.
  • Now open a command prompt and enter the following command: ADB devices.
  • Once this command is executed, the device name will appear in the response, as seen in the picture (if you get a response such as "daemon not operating. daemon was successfully launched," then retry the command).

Get Details Of the App To Be Launched

In your mobile device's Settings menu, choose About Phone.

Start Appium Server

  • Install the program on the supported device or simulator.
  • There are two installation methods for the application.
  • Using play store: Install from the PlayStore directly.
  • Using apk file: Every program has an 'apk' file used for installation. Using the.apk file, one may immediately install the program on the device.
  • To install the program from the command line of the system,
  • Open a command prompt and go to the folder containing the.apk file.
  • Then, enter >adb install example.apk, where the example is the file's name.
  • Install the software
  • Get application information (package name, activity name) Once the program has been installed, collect the following data: Program information such as Package name and Application activity name, since Appium will utilize them to identify the application.

Write Appium Test Script

  • Open Appium Desktop in the system.
  • After opening Appium Desktop, choose the Settings Tab.
  • Notate the server's IP address and port.
  • Tap the Play button to launch the Appium Server.
  • launch Appium Server
  • Once the server has been started, a message stating "Welcome to Appium..." will be shown.

Interact With Elements Using UI Automator Viewer

Open UIAutomator Viewer From Andoird SDK Bundle:

  • To use the tool, browse the Android SDK installation directory.
  • Android SDK>Tools>UIAutomatorViewer.bat
  • When the batch file is executed, the application is launched.

Launch UIAutomator Viewer Using the Command Prompt:

  • Proceed to the command line prompt.
  • Type >uiautomatorviewer
  • Enter.

Run The Script And Automate The App

  • Execute the script as a Java or TestNG application in eclipse.
  • After execution, the Appium logs can be viewed for all activities on the mobile device.

Conclusion

Appium mobile testing is required to meet the requirement for rapid and reliable testing that spans many platforms, devices, and versions. Appium supports functional elements on the HeadSpin test automation platform, while HeadSpin data and insights allow the non-functional aspects of the test. In addition, the most recent version of the platform enables debugging and developing Appium scripts right in the UI without needing an app or desktop client.

Source: This article was originally published at godofsmallthing.com

Top comments (0)