How we achieved seamless Mobile App Automation for a Leading Supply Chain SaaS Platform using Appium and Ranorex
How we achieved seamless Mobile App Automation for a Leading Supply Chain SaaS Platform using Appium and Ranorex
Ranorex

How we achieved seamless Mobile App Automation for a Leading Supply Chain SaaS Platform using Appium and Ranorex

Mobile app testing presents a unique set of challenges for QA teams. One of the key tools to address these challenges is Appium, an open-source test automation framework that allows you to test native, hybrid, and web mobile applications using a single API. However, Appium has its own limitations.

Manually setting up and managing servers for each test run is time-consuming and prone to errors. Additionally, testing across a wide range of devices with different operating systems and screen sizes requires significant effort. Furthermore, Appium tests can be flaky due to unstable network conditions, device interruptions, and changes in the application under test. Finally, establishing a robust and scalable Appium test environment often requires expertise in various tools and technologies.

We came across one such challenge with Appium in one of our recent projects where we had to integrate Appium Server and Android Virtual Devices (AVDs) with Ranorex. The goal was to create a seamless, automated workflow that handles mobile app testing efficiently and fits seamlessly into our existing Azure DevOps pipeline.

This blog outlines step-by-step approach followed to achieve the integration. Whether you’re just starting with mobile test automation or looking for ways to enhance your current pipeline, these insights will guide you through building a robust and scalable solution.

The Challenge

Manually starting and stopping the Appium Server and AVDs to run every test script was a major bottleneck in this test automation process. It was manual and slow which disrupted the seamless flow needed for Azure DevOps pipeline.

The inconsistency in test execution was another big issue. If something wasn’t set up correctly, the entire suite could fail, wasting time and effort. And manual testing could not keep up with testing for multiple devices or parallel tests.

The Solution: Automating AVD and Appium Server in Ranorex Setup

To eliminate manual intervention and achieve seamless automation, we designed a solution that would start the AVD and Appium server at the beginning of each test suite and stop them at the end. This approach involved creating and integrating custom PowerShell and batch scripts and using user code modules in Ranorex to execute them.

1. Setting Up the AVD with PowerShell in Ranorex

We used a PowerShell script (`startAVD.ps1`) to launch the Android Virtual Device (AVD) emulator. This script ensures that Android Studio and the AVD emulator start with administrator privileges and remain ready before the test suite begins.

2. User Code for Automating AVD Initialization

Within Ranorex, we created a user code module named `StartAVD` to handle the script’s execution. This module logs the output and error messages, ensuring clear visibility of the process. This setup ensures the AVD emulator is always ready for test execution.

3. Automating Appium Server Initialization

Next, a batch file (`startAppium.bat`) was added to initiate the Appium server. This batch file runs before each test suite, eliminating the need to start the server manually and avoiding potential errors caused by missed setups.

4. Teardown Scripts for Clean Test Closure

To ensure proper cleanup, we also included `stopAVD.ps1` and `stopAppium.bat` scripts in the test suite’s teardown phase. These scripts close the AVD emulator and Appium server, freeing resources for the next test cycle.

This automated setup and teardown process eliminated the need for manual intervention and provided a stable testing environment every time a test was triggered in the ADO pipeline. By incorporating these user code modules, our Ranorex solution is now fully equipped for seamless mobile test automation in any CI/CD pipeline.

Integrating with Azure DevOps Pipeline

To fully automate the Appium-integrated Ranorex testing within our CI/CD process, we created an Azure DevOps pipeline. This setup allowed us to seamlessly build, execute, and monitor the Ranorex and Appium tests without manual intervention.

Pipeline Structure

Here’s an overview of the YAML pipeline and its steps:

1. Trigger Branch – The pipeline is triggered by changes in the branch, ensuring that the pipeline only runs when relevant updates are made to the testing scripts or framework.

2. Check Java and Maven Versions The initial steps check the installed versions of Java and Maven to ensure the environment is correctly configured for the tests. This provides a quick validation of dependencies before running the tests.

3. Execute the Ranorex Solution with Appium Integration Using the AndroidAppium.exe executable, we initiate the test suite, including the user code modules for starting the AVD and Appium server. The -Wait flag ensures that the pipeline proceeds only after the executable completes, preventing any timing issues.

4. Publish Test Results Finally, the test results are published in JUnit format, making them accessible in the Azure DevOps pipeline dashboard. The configuration includes a “failOnEmptyTestResults” parameter, which halts the pipeline if no results are found, ensuring quick detection of any issues in the test execution.

Benefits of the Automation

By implementing this automated setup for Ranorex and Appium with Azure DevOps, our testing process has become significantly streamlined and efficient. Here are some key benefits we achieved:

  1. Elimination of Manual Intervention
    Previously, manual steps were required to start and stop the Android Virtual Device (AVD) and the Appium server, creating inefficiencies and potential for human error. The integration of startAVD.ps1, startAppium.bat, stopAVD.ps1, and stopAppium.bat scripts within the Ranorex test suite eliminated this need. Now, each testing cycle begins and ends in a fully automated manner, enhancing reliability and freeing up valuable resources for other tasks.
  2. Improved CI/CD Efficiency
    By integrating with Azure DevOps (ADO), we achieved end-to-end automation, from test execution to result reporting. This setup not only removes repetitive tasks but also allows for faster feedback on code changes, which is critical in agile development environments. Developers can now access test results directly within ADO, reducing turnaround time for identifying and fixing bugs.
  3. Enhanced Test Consistency and Reliability
    The automated start and stop processes for AVD and Appium ensure that tests run under consistent conditions every time. By eliminating variations in the test setup, the risk of flaky or inconsistent test results has been greatly reduced. This consistency is essential in maintaining the reliability of our testing suite, enabling more accurate assessments of the code quality.
  4. Scalability for Cross-Platform Testing
    This setup is adaptable to testing different Android devices or configurations, making it scalable for future needs. If we need to test multiple AVD configurations or integrate additional test scripts, this setup can be easily extended. The modularity of the scripts allows us to manage a variety of test scenarios without needing to overhaul the entire testing process.
  5. Real-Time Visibility into Test Results
    Publishing results in JUnit format allows Azure DevOps to capture and display test outcomes in real-time. This visibility provides immediate insights into the success or failure of each test run, enabling the team to quickly address any issues. It also supports data-driven decision-making, as test trends over time can be monitored to assess the stability of new code changes.
  6. Resource Optimization and Cost Savings
    Automating the setup and teardown of the AVD and Appium server helps avoid unnecessary emulator uptime, optimizing resource usage. This streamlined process reduces wear on resources and allows our team to focus on value-added activities rather than spending time on repetitive setup and cleanup tasks.

How We Can Help

Integrating Ranorex with Appium Server, AVDs, and Azure DevOps has transformed our testing approach for a SaaS client. By eliminating manual steps and optimizing our CI/CD pipeline, we’ve boosted productivity, reliability, and scalability. This streamlined solution has turned testing into a strategic asset, enabling faster response times, consistent results, and high-quality releases. With a future-proof framework in place, our QA processes are now more agile, resilient, and ready for continuous growth.

At Enhops, we collaborate with organizations to optimize and automate their testing processes. This enables them to achieve faster and higher-quality releases with minimal production defects.

To experience how this approach can benefit your applications, we invite you to explore our ImpactNOW POC Program. We’ll delve into your applications, construct a test automation framework for chosen scenarios, and assist you in developing a business case to justify your test automation investments.

Avatar photo
Iniyan Shanmugam
Senior QA Automation Engineer

Seasoned QA professional with over 5 years of experience in automation testing and quality assurance. Specializes in tools and technologies such as Ranorex Studio, Selenium WebDriver, and CI/CD pipelines using Azure DevOps. Expertise includes mobile testing for both iOS and Android platforms, as well as integration testing for complex systems. Currently working at Enhops (A ProArch Company), focused on transforming software quality through innovative automation techniques and ensuring seamless delivery with precision and efficiency.