Salesforce Mobile Automation Testing with Appium

Timothy Joseph
Timothy Joseph | May 9, 2023

Salesforce Mobile Automation Testing with Appium

Mobile testing of Salesforce applications is crucial for businesses to effectively manage their customer relationship management (CRM) activities. However, the increased number of features within the Salesforce mobile app poses a challenge in ensuring that it performs optimally. The conventional manual testing approach, involving verification on all potential devices and operating systems, can be time-consuming and prone to errors, ultimately resulting in quality issues and delayed delivery.

Fortunately, Appium offers an automated testing solution that enables swift and efficient testing of the Salesforce mobile app on a range of devices and operating systems. By utilizing Appium, businesses can ensure that the app operates as expected and meets the requirements of both their business and customers.

What Is Appium?

Appium is a widely used open-source test automation framework designed to automate mobile application testing for Android, iOS, and Windows devices. It is well-suited for testing mobile native, hybrid, and web applications. The tool boasts various capabilities, with the following being among the most prominent reasons for its popularity:

  1. Appium leverages common APIs across all platforms, including iOS and Android.
  2. Testers can create automated tests using any programming language, including Java, PHP, Perl, and Python.
  3. Testing teams may create automated test cases using whichever framework they want according to their needs.
  4. Appium offers the convenience of creating cross-platform automation test scenarios.
  5. Since Appium makes use of the WebDriver API, you may use your Selenium testing experience to create Appium tests.
  6. Jenkins and other CI frameworks can be simply integrated with Appium.
  7. Another amazing aspect of this framework is that Appium permits testing on many devices.
  8. A real device and an emulator may be used to execute the Appium test.
 

Tools to Perform Automation Testing Using Appium

If you're looking to automate testing for the Salesforce mobile app using Appium, there are certain tools you need to have installed and set up on your machine to get started. These tools include:

  1. Appium Desktop: It is open-source software that allows you to access the Appium automation server's functionality through a customizable user interface. It is available for Mac, Windows, and Linux.

    It includes all of the components required to operate Appium and acts as a GUI wrapper for the Appium server. Additionally, Appium Desktop has an Inspector, which works similarly to developer tools in a browser to help create locators and to detect components on mobile devices.

  2. Android Studio and Android Emulator: Android Emulator allows you to test your application on a range of devices and Android API versions, which mimic Android devices on your PC, and you can automate the test cases using an emulator if you don't have an Android real device.
  3. Xcode and iOS Simulator: iOS Simulator is a component of Xcode and it allows you to test iOS apps without a real device, it replicates iOS devices on your computer.
  4. Builds: The Salesforce mobile app has been created to operate on an iOS Simulator (.ipa file) or an Android Emulator (.apk file), and both can be automated with Appium. These builds were made specifically for these platforms.
  5. Appium Session:

    Once the above requirements are fulfilled, run the Appium Desktop and launch an Appium session. Kindly follow the below steps:

    For iOS Simulator, Android Emulator, and Android Real Device:

    Open the Appium desktop app and set the ANDROID_HOME and JAVA_HOME environment variables

    1. If you are using the Appium desktop version greater than 1.22.0, then you have to install the Appium inspector separately. [A tool to inspect the mobile elements]
    2. Download Appium inspector from the official GitHub releases.
    3. Start the Appium server and then the Appium inspector.
    4. If you have your real android device, connect it to your machine or else launch android studio and launch the emulator via navigating through the AVD manager.
    5. In Appium inspector, click on the search icon in the top right-hand corner and set your desired capabilities.

      {
      “platformName”: “Android”,
      “deviceName”: “Google Pixel 2”,
      “platformVersion”: “11.0”,
      “app”: “/Users/yourusername/Downloads/Android.apk”,
      “appActivity”: “Yourappactivity”,
      “appPackage”: “yourapppackagename”,
      “automationName”: “UIAutomator2”
      "autoGrantPermissions”:”true"
      "adbExecTimeout”: 60000
      }

      Similarly for iOS Simulator devices:

      1. Download and install the Xcode from the Xcode releases from the web or download it from the app store directly.

      2. Launch the Xcode

      3. Launch the Simulator by right-clicking on the Xcode > Simulator and choose your desired simulator.

      4. In Appium inspector click on the search icon in the top right corner and set your desired capabilities for iOS.

        {
        “platformName”: “iOS”,
        “deviceName”: “iPhone 11”,
        “platformVersion”: “15.2”,
        “app”: “/Users/yourusername/Downloads/simulator.ipa”,
        "bundleId”:”yourappbundleid”,
        “automationName”:”XCUITest”
        }

      5. Click on the save icon and give it a name say ANDROID_CAPS or IOS_CAPS to save your capabilities in the Appium inspector for future use.

      6. Click the start session button on the bottom right side and observe the UI elements.

[Note: For real iOS devices, you need to configure provisioning profiles and distribution/development certificates on your development machine.]

 

Challenges of Salesforce App Test Automation

Automating Salesforce App testing comes with its own set of challenges. Let us explore some of these challenges and how QASource can assist you in addressing them:

  • Dynamic Contents

    The Salesforce Forms platform is dynamic. Users cannot rely on xpath or an index-based locator method as a result. Users should instead employ a relative locator or label method. QASource provides an open-source automation framework, which comes with built-in Salesforce application compatibility, reduces the amount of work required to manage complicated form filling, and offers label-based locator techniques. Additionally, it contains components built in to manage a variety of complicated controls, like a grid, selector, date picker, and others.

  • Hybrid App

    Salesforce1 is by definition a hybrid app and faces all of the same difficulties as hybrid apps do. Some components are native, while others are HTML5-developed. Hence, many components cannot be identified in automation.

    The following are the main difficulties in automating hybrid apps as opposed to native apps:

    • Context: In general, hybrid apps don't use components of a native UI and operate entirely in a WebView. This implies that to find these items for the driver, when an app is opened, you must transition between contexts.
    • Selectors: Since elements are used in the context of a WebView, they are fundamentally the same as those used by web browsers. Using the Chrome Remote Debugger to investigate them is a simple approach.
    • Touch Actions: WebView does not fully enable touch actions, it might be challenging to simulate them in a hybrid app.
  • Security Constraints

    Due to Android security measures, Salesforce frequently disallows users from taking screenshots on Android. When this occurs, you might have to negotiate with the developer to turn off the Android security flag or use third-party utilities.

 

Conclusion

When choosing an automation framework for the Salesforce Mobile App, it is critical to consider your app and business objectives. To ensure the best possible coverage for your unique Salesforce testing requirements, QASource, a leading software testing company, can assist you in identifying the optimal automation approach.

QASource has developed several Appium-based Java libraries that perform various operations to assist clients in testing their Salesforce applications. These operations include login, logout, search, lead creation, account, and contact management, opening account details, viewing account cases and opportunities, and retrieving account owner details.

Visit QASource now to learn more about how you can enhance the testing process for your Salesforce applications and leverage the expertise of a trusted software testing partner.

Disclaimer

This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.