Speed up Appium iOS Automation

Appium users know the process of iOS automation which is a time consuming one. Here, I’m going to list down some good practices to improve automation efficiency and reduce test execution time.

Let’s start,

  1. derivedDataPath capability

Usage:

capabilities.setCapability("derivedDataPath", "/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-alwvnomvwrdtzoaxbbkniqrpcdpp");capabilities.setCapability("usePrebuiltWDA", true);

Note: WDA derived data folder will only create if you have properly done the WDA setup. Refer here

2. iOSNsPredicate locator strategy

Use predicate string locator to find the app elements instead of Xpath and other legacy locators. Predicate string locator is significantly faster than other locators. So, the test execution time will reduce.

Usage:

iOSDriver
.findElementByIosNsPredicate("value == \"Enter Username\"");
or @iOSXCUITFindBy(iOSNsPredicate = "value == \"Enter Username\"")
public IOSElement enterPassphraseTxtBx;

3. iOSClassChain locator strategy

Same as the previous locator, the class chain locator is also effective in terms of finding elements quickly. This is the best alternative to the Xpath. Writing the class chain is very much similar to the Xpath. Check out here for the rules to write valid class chain locators.

Usage:

iOSDriver
.findElementByIosClassChain("**/XCUIElementTypeButton[`label == \"Settings\"`]");
or@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == \"Settings\"`]")
public IOSElement backSettingsBtn;

4. bundleId capability

Use bundleId capability instead of app capability. Bundle id capability will start the already installed application in the device instead app capability will install the application to the device and then start the AUT. And we need the “.ipa” file or “.app” file to start the iOSDriver. Refer here.

Usage:

capabilities.setCapability("bundleId", "com.demo.testapp");

5. noReset capability

this capability will avoid closing the driver for every test and it won’t clear the AUT data when the driver starts. If your app is has a login module, then this will be very helpful. You don’t need to log in to the app every time as noReset capability will not clear the app data while the driver starts.

Usage:

capabilities.setCapability(MobileCapabilityType.NO_RESET, true);

The above 5 tips will significantly improve your iOS automation efficiency and reduce the execution time. Try it in your code and check the difference.

Automation QA Engineer by profession. Learning iOS Development.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store