Seamless Transition: Migrating Appium Client Library from 8.2.3 to 9.2.3

A testing library is a collection of code and data specifically designed to aid in the development and execution of software tests. It provides tools and functionalities that help testers and developers create, run, and manage tests efficiently, ensuring the software behaves as expected under various conditions. At Halodoc, we continuously develop features to address customer pain points, helping them make the most of our product and simplify healthcare. One essential practice in software development is keeping libraries up to date, which brings several benefits, such as bug fixes, new features, improved performance, and enhanced stability, compatibility, and security.

In this blog, we will share some of our key insights and learnings from migrating the Appium Java Client from version 8.2.3 to 9.2.3.

Appium Java Client

The Appium Java Client provides Java language bindings for writing Appium tests that conform to the WebDriver protocol. It enables developers to write test scripts in Java for automating mobile applications across various mobile platforms.

Changes in Appium Java Client v8.2.3

Here’s the list of Deprecated and Removed APIs:

  1. MobileBy class.
  2. launchApp, resetApp, and closeApp methods.
  3. SupportsLegacyAppManagement container.
  4. ByAll class.
  5. AndroidMobileCapabilityType interface.
  6. MobileCapabilityType interface.
  7. MobileOptions class.
  8. YouiEngineCapabilityType interface.
  9. startActivity method from AndroidDriver.

Benefits of Migrating to Appium Java Client v9.2.3

Migrating to Appium Java Client v9.2.3 brings a range of benefits that can significantly enhance your mobile testing framework:

  1. Enhanced Testing Capabilities:
    The new version introduces updated features that allow you to create more sophisticated and effective test cases. This includes improved support for the latest mobile operating systems, such as Android 13 and Android 14, and devices like the Samsung Galaxy S23. These updates enable comprehensive testing across a wide range of platforms and devices, ensuring compatibility and optimal performance for all users.
  2. Enhanced Features: The new version includes updated features and improvements that can enhance your testing capabilities. This includes better support for the latest versions of mobile operating systems, such as Android 14, and the newest devices like the Samsung Galaxy S23 and Google Pixel 8. These enhancements ensure more reliable and comprehensive testing across a broad range of Android platforms and devices.
  3. Bug Fixes: Appium Version 9.2.3 includes several bug fixes and enhancements that resolve issues from previous versions, leading to increased stability and reliability in your test automation processes.
  4. Performance Improvements: Upgrading to the latest version can lead to performance enhancements, making your test executions faster and more efficient. These improvements can be seen in areas such as reduced test execution time, optimized memory usage, faster loading of elements, and improved stability during test runs, especially on complex applications and newer Android devices.
  5. Compatibility: As mobile platforms and Appium itself evolve, new library versions ensure compatibility with these changes, reducing the risk of integration issues.
  6. Security: New releases of Appium, Android SDK, and other related tools often include patches for security vulnerabilities. These patches protect your testing environment from potential threats, such as malware or unauthorized access.
  7. Support and Documentation: By using the latest version, you benefit from up-to-date documentation and support, which can help resolve issues more effectively and ensure you’re utilizing the library to its full potential.
  8. Future-Proofing Your Testing Framework:
    Staying up to date with the latest releases ensures that your testing framework is ready for future updates and advancements in mobile technology. This proactive approach ensures your testing framework remains up-to-date with the latest technology, minimizing the need for major changes in the future.

Integrating the Appium Java Client into Your Test Framework

To integrate the Appium Java Client into your test framework, you need to include the necessary dependencies in your build configuration. Here’s how to do this for both Gradle and Maven:

Gradle

Add the following to your build.gradle file:

Maven

Add the following to your pom.xml file:

Integrating the Selenium to Your Test Framework

Selenium v4.19.0 is required for Appium Java Client v9.2.3 to ensure compatibility with the W3C WebDriver protocol. Selenium 4 introduces substantial updates and improvements, including full support for this protocol, which Appium Java Client v9.2.3 is designed to adhere to. This alignment between Selenium and Appium is crucial for seamless integration, ensuring that both tools work harmoniously together. Additionally, Selenium 4 brings enhancements such as updated features, bug fixes, and improvements in stability, performance, and security. These updates are essential for maintaining a robust, efficient, and reliable automation framework.

To add the Selenium Java Client to your test framework, you need to include the appropriate dependencies in your build configuration. Here's how you can do it for both Gradle and Maven:

Gradle

Add the following to your build.gradle file:

Maven

Add the following to your pom.xml file:

Enhanced Strict W3C Specification

With the release of Appium Java Client v9.2.3, the client now supports Selenium 4, ensuring strict W3C compliance. Here's a detailed explanation of this compatibility:

Transition from JSON Wire Protocol to W3C Protocol

  • Previously JSON Wire Protocol (JWP): Previously, Appium relied on the JSON Wire Protocol as a mediator between client libraries and WebDrivers. This protocol transferred data between the client and the server, allowing the server to understand the protocol regardless of the programming language used to create the program.
  • W3C Protocol: Appium Java Client v9.2.3 fully supports the W3C WebDriver standard. This means that the Previously JWP-based servers are no longer supported, and it won't be possible to use the new client version with them. The W3C protocol provides a more standardized approach to browser automation, ensuring better consistency and compatibility across different browsers and platforms.

To ensure compliance with the W3C WebDriver protocol, it is recommended to define capabilities using specific option builders that inherit from the BaseOptions class. These builders provide a structured and standardized way to set capabilities for driver creation, making it easier to configure and manage the desired settings for different browsers or devices. By using these option builders, you can ensure that your test scripts are more maintainable, clear, and compatible with the latest WebDriver standards, enhancing the reliability and flexibility of your test automation framework.

Significant Changes in the Latest Version

LaunchApp/ResetApp/CloseApp

The AppiumDriver methods launchApp, resetApp, and closeApp were removed in Appium version 8.2.3 to better align with the WebDriver protocol, reduce redundancy, and increase flexibility in automation scripts. To achieve similar functionality, you can now use the executeScript method with specific commands: mobile: launchApp to launch an app, mobile: clearApp followed by mobile: launchApp to reset an app, and mobile: terminateApp to close an app. These alternative methods provide more customization and control, adhering to the updated Appium Java Client standards and encouraging best practices.

MobileBy

  • The MobileBy class, which was used for mobile element location strategies, has been completely removed from the v8.2.3. This class often led to confusion regarding which locator strategy to use.
  • Automation developers should transition to using AppiumBy, which offers a more consistent and modern approach to element identification across different platforms.

ByAll

  • ByAll used in Appium to combine multiple locator strategies into one query, allowing elements to be found using any of the specified locators.
  • Removed in favor of the By class from the Selenium library to maintain consistency across automation frameworks.
  • The By class is more widely adopted and understood, which simplifies maintenance and fosters better collaboration.
  • Automation Developers who used ByAll should switch to the By class for combining locators, aligning with standard practices and benefiting from a universally recognized approach.

Use of BaseOptions Instead of DesiredCapabilities

  • The DesiredCapabilities class has been replaced by BaseOptions for configuring desired capabilities in Appium.
  • This change streamlines the configuration process and enhances code clarity. BaseOptions provides a more intuitive and modern interface for setting driver options, which simplifies configuration management and aligns with updated Appium standards. This transition ensures better maintainability and easier understanding of capabilities.
  • Automation developers need to update their existing setup code to use BaseOptions to remain compatible with the latest Appium versions.
  • Provides a clearer, more intuitive method for configuring capabilities, making it easier to manage driver options and maintain code.

AndroidMobileCapabilityType

  • The AndroidMobileCapabilityType interface has been deprecated. Automation developers should now use UIAutomator2 driver options for configuring Android capabilities.
  • This update simplifies capability configuration and promotes modern automation tools. UIAutomator2 offer improved performance and reliability for Android automation.
  • Update existing code that uses AndroidMobileCapabilityType to the new driver options to ensure compatibility with Appium 9.2.3 and future versions.
  • By using UIAutomator2 driver options, automation developers can take advantage of improved performance and reliability for Android automation, aligning with best practices in the industry.

MobileCapabilityType

  • The MobileCapabilityType interface has been deprecated. Automation developers should now configure mobile capabilities using driver options directly.
  • This change simplifies the configuration process, offering a more streamlined approach. Directly using driver options results in clearer and more flexible capability configurations, which improves code readability and maintainability.
  • Update existing code that relies on MobileCapabilityType to use driver options directly. This update ensures compatibility with Appium 9.2.3 and future versions.
  • Provides a more intuitive and manageable way to configure capabilities, enhancing the overall code quality and maintenance.

Migrating From Appium v1 To v2

I am briefly explain how to install Appium v2. Appium v2 is the latest major release of the Appium framework, an open-source tool extensively used for automating mobile, web, and desktop applications. This version marks a significant advancement over its predecessors by introducing a more modular architecture that separates the core Appium server from its drivers and plugins. This change is designed to increase flexibility, reduce unnecessary overhead, and better adapt to the rapid updates of mobile operating systems and browsers.

How to Install Appium v2

To install Appium v2, you first need to ensure that you have Node.js version 16 or higher and npm version 8 or higher. Use below command to install Appium v2:

However, this command only installs the core Appium server and does not include any drivers or plugins.

Since Appium 2.0 has a modular architecture and separates the WebDrivers it supports, you need to manually install the specific drivers and plugins required for your testing needs. For example, to automate Android devices, you would install the UiAutomator2 driver using:

For iOS devices, you would install the XCUITest driver with:

To update any installed drivers, use the following command:

Here, <driverName> should be replaced with the actual name of the driver you want to update. You can see a list of installed drivers by running:

Improvements and Optimizations in the Test Suite

After migrating to Appium v9.2.3, we observed the following improvements in our automation test suites:

  1. Faster Execution Times: Performance optimizations can lead to quicker execution of tests, reducing the time required for your entire test suite to complete. This is beneficial for continuous integration and continuous delivery (CI/CD) pipelines. We achieved a reduction of approximately 15% in our automation suite runtime.
  2. Reduced Flakiness: Minimize flaky tests, leading to more reliable and consistent test results. This means fewer false positives and negatives in your test suite.
  3. Detailed Logs: Enhanced logging capabilities provide more detailed information about test execution, making it easier to diagnose and troubleshoot issues.
  4. Increased Compatibility: Better support for the latest versions of mobile operating systems and devices. This means your test suite is more likely to work seamlessly across a wider range of environments.

Conclusion

Updating to Appium Java Client v9.2.3 brings significant improvements, including enhanced compatibility with the W3C WebDriver protocol, a streamlined approach to setting capabilities, and the adoption of modern element locator strategies, which ensure better performance, consistency, and maintainability for automation projects.

Additionally, installing Appium 2.0 requires a new approach, as it decouples its supported WebDrivers, allowing for selective installation of necessary drivers and plugins, thus providing greater flexibility and control over the testing environment. Staying updated with the latest versions of software libraries like the Appium Java Client is crucial for leveraging new features, improving performance, and maintaining security and compatibility. Our migration to v9.2.3 has set the stage for more robust and efficient automation testing, ensuring that our framework is aligned with the latest industry standards.

References

Join Us

Scalability, reliability and maintainability are the three pillars that govern what we build at Halodoc Tech. We are actively looking for engineers at all levels, and if solving complex problems with challenging requirements is your forte, please reach out to us with your resume at careers.india@halodoc.com.

About Halodoc

Halodoc is the number 1 all around Healthcare application in Indonesia. Our mission is to simplify and bring quality healthcare across Indonesia, from Sabang to Merauke. We connect 20,000+ doctors with patients in need through our Tele-consultation service. We partner with 3500+ pharmacies in 100+ cities to bring medicine to your doorstep. We've also partnered with Indonesia's largest lab provider to provide lab home services, and to top it off we have recently launched a premium appointment service that partners with 500+ hospitals that allow patients to book a doctor appointment inside our application. We are extremely fortunate to be trusted by our investors, such as the Bill & Melinda Gates Foundation, Singtel, UOB Ventures, Allianz, GoJek, Astra, Temasek, and many more. We recently closed our Series D round and In total have raised around USD$100+ million for our mission. Our team works tirelessly to make sure that we create the best healthcare solution personalised for all of our patient's needs, and are continuously on a path to simplify healthcare for Indonesia.