Blog
>
Technology

Appium with Parallel Execution: PART — 1

Shreyas Jain
I
February 10, 2022

Photo by Carl Heyerdahl on Unsplash

Setting Up the Plot:

Manual Testing becomes challenging when there are too many features to be checked. Thankfully we have automation to deal with time-consuming Manual checks. When it comes to Mobile Native Apps / Hybrid Apps, the usage of app/s is higher, since almost everyone has a handheld device. Automating, Maintaining, and Improving the automation code for such fast-growing Apps are also of equal importance.

Usually, when we start with Mobile App Automation, we start with one Device, one Appium instance, and one execution command. This works fine as long as the product that we are delivering is very limited in nature. But this is not the case, the Test cases grow exponentially as the feature gets added to the App. We will reach a point where automation starts taking more time than expected. The obvious solution is to move towards parallel execution, which will help us to reduce the automation execution time.

There might be a lot of compromises like Hardcoding, Not maintaining Design standards, etc. Jumping directly from sequential execution to parallel execution is not simple for everyone / every automation framework.

In my case, I was using:

  • One Emulator.
  • One Appium Instance from the MAC terminal.
  • Automation framework — Cucumber + JUnit + Maven + Java.

The following approaches are my experiences when it comes to moving towards parallel execution. To demonstrate with an example:

  • Source code used :

https://github.com/shreyas18jan/AppiumExample

  • 2 Devices: one Emulator and one real device. (can be scaled for more devices also)

Approach 1: Use Separate Instances of Appium for Separate Devices at the same time.

  • The easy way to create multiple instances of Appium is to use the -p option during Appium start. So Created 2 instances of Appium for 2 devices in 2 different terminal tabs.
    Example:

In terminal — 1

appium -p 4724

In terminal — 2

appium -p 4723

  • Since I have 2 devices now, started organizing Tags in the feature file so that I can create 2 groups. One tag runs against Emulator and the Other tag runs against the real device.
  • Moved the Desired Capabilities values to the property file. If needed we can override from the maven property during maven command execution. Using the above steps, I came up with the following 2 maven commands.
    Example:

In terminal — 3

mvn test -Dappium.address=”http://0.0.0.0:4723/wd/hub" -Ddevice.udid=Custom-Emulator -Dcucumber.filter.tags=@FeatureMultipleOf10

In terminal — 4

mvn test -Dappium.address=”http://0.0.0.0:4724/wd/hub" -Ddevice.udid=<REAL-UDID> -Dcucumber.filter.tags=@FeatureMultipleOf3

Pros:

  • Execution time is reduced.

Cons:

  • Feature file Level or Scenario Level parallel execution is not present.
  • Multiple Maven commands / Multiple Tags are required.
  • Starting and Stopping Appium will be a manual task. (Can be overcome, If we use Jenkins and figure out a way to Start before automation and Stop after automation)

Approach 2: Instead of the New Appium instance, use the existing Appium instance with a Different systemports.

Leverage Appium’s advantage, which allows us to automate multiple Android sessions on a single machine on a single server instance.

appium/parallel-tests.md at master · appium/appium

Appium provides a way for users to automate multiple Android sessions on a single machine on single server instance…

github.com

  • One small change is added i.e., systemPort desired capability:

capabilities.setCapability(“systemPort”, desiredCapabilitiesProp.getProperty(“appium.system.port”));

Now the Appium URL can be shared across multiple runs. I changed the maven commands to the following things.
Example:

In terminal — 3

mvn test -Dappium.system.port=8230 -Ddevice.udid=Custom-Emulator -Dcucumber.filter.tags=@FeatureMultipleOf10

In terminal — 4

mvn test -Dappium.system.port=8231 -Ddevice.udid=Custom-Emulator -Dcucumber.filter.tags=@FeatureMultipleOf3

Pros: (Better than Approach 1)

  • Execution time is reduced.
  • Only one Appium is used in this approach, as long as different SystemPort is passed during execution, automation works smoothly.

Cons:

  • Feature file Level or Scenario Level parallel execution is not present.
  • Multiple Maven commands / Multiple Tags are required.

In the next blog, we will discuss a few more approaches to deal with Parallel Execution with Appium for the above problem statement.

QA
Automation Testing
Automation Script
Agile Testing

About Quinbay

Quinbay is a dynamic one stop technology company driven by the passion to disrupt technology today and define the future.
We private label and create digital future tech platforms for you.

Digitized . Automated . Intelligent