Tips to enhance/optimize appium automation framework.

Satheesh Kumar
dubizzle Engineering
3 min readFeb 12, 2019
Mobile Testing Automation Tool

The most commonly used stack for android automation is [Appium,Java,TestNG]. Following are few tips to enhance/optimize this framework.

A) Setup up Re-Try logic using TestNg: Retry logics will ensure any random flakiness with the test is handled automatically to ensure seamless running of automation tests in the CD Pipeline.

Implementation Steps:

Step1: Create a RetryAnalyzer class which implements IRetryAnalyzer and can monitor the test results and informs TestNg runner to re-run failed test case.

Now, your test methods needs to be annotated with “RetryAnalyzer.class”, so that it can send the tests results status to it.

B) Enable Parallelism using Latest Appium Driver: If you are using in-house testing infrastructure, (Note: Preference will be to use Cloud Testing solutions), you need to enable Parallelism using Latest Appium Driver to keep the implementation strategy simpler.

In the older versions of appium server, we would require to start separate Appium server instances to enable paralell testing on different real devices/simulators, however the latest version of appium server supports paralellism using single appium server itself.

Implementation Steps:

Step 1: Update your base driver method to accept parameters like udid and systemport.

Step2: TestNg.xml file needs to be updated, to pass these parameter values to base driver method. [Note: You can specify any port number between8200 to 8299]

C) Implement UI Scrolling using UIAutomator(UiScrollable): Latest versions of Appium server doesnt have swipe/scrollTo methods. You need to use UIAutomator for this. Different ways of implementing scrolling using UIScrollable class are mentioned below:

public void scrollForwardByResourceID(String resourceID) {

driver.findElementsByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId('"+resourceID+"')).scrollForward()");

}

public void scrollForwardByResourceID(String resourceID, int steps) {

driver.findElementsByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId('"+resourceID+"')).scrollForward("+steps+")");

}

public void scrollBackwardByResourceID(String resourceID, int steps) {

driver.findElementsByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId('"+resourceID+"')).scrollBackward("+steps+")");

}

Other important methods available in UiScrollable class are as follows: scrollDescriptionIntoView(String text), scrollTextIntoView(String text), scrollIntoView(UIObject obj). Complete list of referene can be found here.

--

--

Satheesh Kumar
dubizzle Engineering

Test Automation Specialist— Continuous Testing (Selenium, Appium, XCUITest, CI/CD, Jenkins/Gitlab-CI/Bitrise)