Examples of App Activity Usage in Appium Testing
Here are a few examples to demonstrate the use of App Activity in Appium Testing:
1. When Testing Different User Flows
Sometimes the Android app may have different flows that a user can go through. This includes Mobile Games which have different flows for different users depending on their game level for example. To do this, we can use a set of conditional statements:
Kotlin
if (userFlow.equals( "flowA" )) { capabilities.setCapability( "appActivity" , "com.example.sampleapp.ActivityA" ) } else if (userFlow.equals( "flowB" )) { capabilities.setCapability( "appActivity" , "com.example.sampleapp.ActivityB" ) } |
2. Navigating To A Specific Screen
To allow the test to be executed on a specific screen, the Appium Screen can be configured like this:
Kotlin
capabilities.setCapability( "appActivity" , "com.example.sampleapp.LoginActivity" ) |
The test here will thus execute at the Login Screen that is represented by LoginActivity. This eliminates any redundant Navigation.
3. When Testing Specific Functionality
Not only is it possible to test the specified screen but also possible to test specific functionality. For example, the Login/Logout functionality on a specified screen could be tested as shown:
Kotlin
driver.findElementById( "logoutButton" ).click() capabilities.setCapability( "appActivity" , "com.example.sampleapp.LoginActivity" ) |
Understanding App Activity in Appium | How it Works, Importance, Best Practices
Appium is integral to UI Automation within different domains in Tech: Mobile, Web, and even Desktop. The platform aims to streamline Software Testing through the following goals as outlined by its creators:
- Make platform-specific automation capabilities available under a cross-platform, standard API.
- Allow easy access to this API from any programming language.
- Provide tools to enable convenient community development of Appium extensions.
Appium is a suitable choice for Mobile Developers who want to benefit from the automation of UI Testing due to its ease of use and versatility. This article seeks to define what App Activity is in the context of Appium and Android.
Contact Us