Enhancing Test Reliability, Repeatability, and Speed with Appium Capabilities

In the world of mobile test automation, starting an Appium session goes beyond mere initialization. Itโ€™s about optimizing our testing environment to achieve ๐’“๐’†๐’๐’Š๐’‚๐’ƒ๐’Š๐’๐’Š๐’•๐’š, ๐’“๐’†๐’‘๐’†๐’‚๐’•๐’‚๐’ƒ๐’Š๐’๐’Š๐’•๐’š, and ๐’”๐’‘๐’†๐’†๐’…. This optimization is accomplished through session initialization parameters known as ๐’ธ๐’ถ๐“…๐’ถ๐’ท๐’พ๐“๐’พ๐“‰๐’พ๐“ฎ๐“ˆ. These capabilities allow us to fine-tune how Appium operates, ensuring our tests are consistent and efficient.

Lana Begunova
4 min readMay 17, 2024

Letโ€™s explore how we can enhance our Appium sessions to improve test ๐’“๐’†๐’๐’Š๐’‚๐’ƒ๐’Š๐’๐’Š๐’•๐’š, ๐’“๐’†๐’‘๐’†๐’‚๐’•๐’‚๐’ƒ๐’Š๐’๐’Š๐’•๐’š, and ๐’”๐’‘๐’†๐’†๐’….

Cross-Platform Capabilities

๐’๐’๐‘น๐’†๐’”๐’†๐’•

By default, Appium resets the state of your device after each session to ensure a clean slate for subsequent tests. However, if your tests donโ€™t require this level of reset, you can set the โ€œnoResetโ€ capability to โ€œtrueโ€. This avoids time-consuming cleaning routines, significantly speeding up your tests without compromising repeatability.

๐’‡๐’–๐’๐’๐‘น๐’†๐’”๐’†๐’•

For scenarios where ensuring a completely clean state is crucial for test reliability, use the โ€œfullResetโ€ capability. Setting this to โ€œtrueโ€ goes beyond the default cleanup, providing a thorough reset that guarantees no residual data from previous sessions can affect your current test.

๐’Š๐’”๐‘ฏ๐’†๐’‚๐’…๐’๐’†๐’”๐’”

Running simulators or emulators in headless mode can boost performance, especially in resource-constrained environments. The โ€œisHeadlessโ€ capability, when set to โ€œtrueโ€, enables this mode, enhancing the speed of your test executions while maintaining reliability.

Android-Specific Capabilities

๐’…๐’Š๐’”๐’‚๐’ƒ๐’๐’†๐‘จ๐’๐’…๐’“๐’๐’Š๐’…๐‘พ๐’‚๐’•๐’„๐’‰๐’†๐’“๐’”

The UiAutomator2 driver continuously checks for toast messages, consuming valuable CPU cycles. If your tests donโ€™t require this feature, disabling it with the โ€œdisableAndroidWatchersโ€ capability can improve performance and consistency, especially in scrolling actions.

๐’‚๐’–๐’•๐’๐‘ฎ๐’“๐’‚๐’๐’•๐‘ท๐’†๐’“๐’Ž๐’Š๐’”๐’”๐’Š๐’๐’

Setting โ€œautoGrantPermissionโ€ to โ€œtrueโ€ ensures that Appium automatically grants necessary app permissions, avoiding interruptions from system popups. This streamlines our tests, enhancing both reliability and speed.

๐’”๐’Œ๐’Š๐’‘๐‘ผ๐’๐’๐’๐’„๐’Œ

Managing device unlocking outside of Appium? Use the โ€œskipUnlockโ€ capability to skip Appiumโ€™s default unlock routine. This saves time during test initialization, ensuring faster and more consistent test starts.

๐’‚๐’‘๐’‘๐‘พ๐’‚๐’Š๐’•๐‘ท๐’‚๐’„๐’Œ๐’‚๐’ˆ๐’† & ๐’‚๐’‘๐’‘๐‘พ๐’‚๐’Š๐’•๐‘จ๐’„๐’•๐’Š๐’—๐’Š๐’•๐’š

When the appโ€™s launch activity differs from its main activity, use โ€œappWaitPackageโ€ and โ€œappWaitActivityโ€ to specify the correct activity. This ensures Appium waits for the right activity, stabilizing the session start process and enhancing test reliability.

๐’Š๐’ˆ๐’๐’๐’“๐’†๐‘ผ๐’๐’Š๐’Ž๐’‘๐’๐’“๐’•๐’‚๐’๐’•๐‘ฝ๐’Š๐’†๐’˜๐’”

Enabling โ€œignoreUnimportantViewsโ€ compresses the Android layout hierarchy, simplifying the XML structure and speeding up XPath queries. This reduces the time it takes to retrieve page sources, improving overall test speed.

iOS-Specific Capabilities

๐’–๐’”๐’†๐‘ท๐’“๐’†๐’ƒ๐’–๐’Š๐’๐’•๐‘พ๐‘ซ๐‘จ & ๐’…๐’†๐’“๐’Š๐’—๐’†๐’…๐‘ซ๐’‚๐’•๐’‚๐‘ท๐’‚๐’•๐’‰

Avoid rebuilding WebDriverAgent every time by setting โ€œusePrebuiltWDAโ€ to โ€œtrueโ€. Specify the path to the prebuilt binary with โ€œderivedDataPathโ€, saving time on session startup and ensuring faster test executions.

For large apps, using JSON instead of XML for the app hierarchy can significantly speed up source retrieval. Set โ€œuseJSONSourceโ€ to โ€œtrueโ€ to enable this optimization, enhancing test speed without compromising reliability.

๐’Š๐’๐’”๐‘ฐ๐’๐’”๐’•๐’‚๐’๐’๐‘ท๐’‚๐’–๐’”๐’†

Large iOS apps can take time to launch. Use the โ€œiosInstallPauseโ€ capability to add a delay (in milliseconds) after WebDriverAgent detects the app is online, ensuring itโ€™s fully ready before the test proceeds. This improves the reliability of test starts.

๐’Ž๐’‚๐’™๐‘ป๐’š๐’‘๐’Š๐’๐’ˆ๐‘ญ๐’“๐’†๐’’๐’–๐’†๐’๐’„๐’š

If you encounter typing errors during tests, adjust the typing speed with โ€œmaxTypingFrequencyโ€. Lower values slow down typing, reducing errors and improving the reliability of text input actions.

๐’“๐’†๐’‚๐’๐‘ซ๐’†๐’—๐’Š๐’„๐’†๐‘บ๐’„๐’“๐’†๐’†๐’๐’”๐’‰๐’๐’•๐’•๐’†๐’“

For faster and more reliable screenshots on real devices, use the โ€œrealDeviceScreenshotterโ€ capability with the โ€œidevicescreenshotโ€ binary from the libimobiledevice suite. This ensures quicker and more consistent screenshot captures.

๐’”๐’Š๐’Ž๐’‘๐’๐’†๐‘ฐ๐’”๐‘ฝ๐’Š๐’”๐’Š๐’ƒ๐’๐’†๐‘ช๐’‰๐’†๐’„๐’Œ

Element visibility checks can be unreliable with XCUITest. The โ€œsimpleIsVisibleCheckโ€ capability offers an alternative visibility check that might be more reliable for your app, though it may take longer. This trade-off can enhance the reliability of your tests.

Conclusion

Optimizing your Appium sessions with these capabilities can significantly enhance the reliability, repeatability, and speed of your mobile tests. Whether dealing with cross-platform nuances or platform-specific challenges, these capabilities provide the tools you need to ensure your tests run smoothly and efficiently. Stay updated with the latest Appium documentation to leverage new features and capabilities as they become available.

Mastering these capabilities will ensure your test automation runs like a well-oiled machine, giving you more time to focus on developing great apps.

๐“—๐“ช๐“น๐“น๐”‚ ๐“ฝ๐“ฎ๐“ผ๐“ฝ๐“ฒ๐“ท๐“ฐ ๐“ช๐“ท๐“ญ ๐“ญ๐“ฎ๐“ซ๐“พ๐“ฐ๐“ฐ๐“ฒ๐“ท๐“ฐ!

I welcome any comments and contributions to the subject. Connect with me on LinkedIn, X , GitHub, or Insta.

If you find this post useful, please consider buying me a coffee.

#Appium #MobileTesting #Automation #QA #DevOps #TechInsights #TechTips #TestOptimization #TestingEfficiency #Selenium #TechBoost

--

--

Lana Begunova

I am a QA Automation Engineer passionate about discovering new technologies and learning from it. The processes that connect people and tech spark my curiosity.