Automated Testing with the Salesforce Mobile App & Appium | Salesforce Developers Blog

Have you been looking to develop automated tests for the Salesforce mobile app? I’m excited to share that it is now easier than ever!

Salesforce has introduced new mobile tools for building, previewing, and debugging for mobile. The new Salesforce mobile app simulator build for iOS, and the Salesforce mobile app emulator build for Android, enable developers to preview and debug Lightning components and Lightning applications on virtual devices. They help you make sure that the components and applications that you are building work well on mobile and especially within the Salesforce mobile app.

If this is your introduction to the Salesforce mobile app simulator and emulator builds, check out the following resources:

What do these new tools mean for you? As a tester, this means that you can download builds of the Salesforce app that have been compiled to run on an Android Emulator or iOS Simulator and use them to develop automated tests on mobile devices. In this blog, you will learn how to use the Salesforce mobile app builds for an iOS Simulator and Android Emulator with an automated testing tool. Please note: This blog is not an endorsement of these tools or a commitment to support them.

We will go through the process of using Appium as our example. Appium is an open source tool for automating native, mobile web, and hybrid applications on Android and iOS applications. There are many different automated testing tools available.

In addition, Appium utilizes the WebDriver API, so if you’re familiar with writing browser tests with Selenium, you can apply that knowledge to Appium.

After this blog, you will be able to:

  • Set up the the Appium tools needs for automated testing
  • Launch an Appium session on your computer that can be used to build automated tests

Setting up your tools

To do automated testing with the Salesforce mobile app using Appium, you will need the following tools. If you are using different tooling, you can replace the Appium Desktop with your desired automated testing tools.

  • Appium Desktop: A GUI wrapper around the Appium server, it comes bundled with everything you need to run Appium. Appium Desktop also provides an Inspector, which aids in creating locators to identify elements on mobile devices similar to developer tools in a browser.
  • Android Studio and Android Emulator: The Android Emulator emulates Android devices on your computer, so that you can test Android apps without the need for a physical device. The Android Emulator runs on Windows, MacOS, and Linux, and it is available as part of Android Studio.
  • XCode iOS Simulator: The iOS Simulator simulates iOS devices on your computer, allowing you to test iOS apps without the need for a physical device. The iOS Simulator is available as part of XCode and is only available on macOS.
  • Salesforce App Emulator/Simulator build: The iOS Simulator and Android Emulator builds are builds of the Salesforce mobile app that have been compiled to run on an Android Emulator or iOS Simulator and can be automated with Appium.

The tools listed above need to be downloaded, installed, and configured. Please follow these instructions to set up your mobile testing environment. Setting up these tools gives your company ways to test your features for the Salesforce mobile app.

Launch an Appium session

You now have Appium Desktop, along with either Android Studio and Android Virtual Device or XCode and iOS Simulator installed, and you have the emulator/simulator build of the Salesforce mobile app downloaded. You’re ready to run Appium Desktop and launch an Appium session!

  1. Open the Appium Desktop app.
  2. If you will be testing on an Android Emulator:
    1. Click Edit Configurations.
      1. Set the ANDROID_HOME and JAVA_HOME environment variables.
      2. Click Save and Restart.
  3. Click the Start Server button.
  4. Open the New Session window:
    1. MacOS
      1. From the Appium menu bar → New Session
    2. Windows
      1. File → New Session
  5. Configure Desired Capabilities:
    1. Desired Capabilities tell Appium all of the details it needs to know to configure your testing session. We’ll use some basic Desired Capabilities to create our first Appium session. For additional documentation, see Appium Desired Capabilities.
    2. For Android:
      1. Open Android Studio and launch the Virtual Device that you want Appium to connect to.
      2. In Appium Desktop, click the Edit icon in the JSON representation section and paste in the JSON below:
        1. {
          “platformName”: “Android”,
          “deviceName”: “Pixel 3 XL”,
          “platformVersion”: “10.0”,
          “app”: “/Users/dstead/Downloads/SalesforceApp-Emulator-226.010.0-Android.apk”,
          “appActivity”: “com.salesforce.chatter.Chatter”,
          “appPackage”: “com.salesforce.chatter”,
          “automationName”: “UIAutomator2”
          }
      3. Click the Save icon.
      4. Modify the following Desired Capabilities:
        1. deviceName — the name of the virtual device that you have created in the Android Virtual Device Manager
        2. platformVersion — the version of Android that the virtual device is running
        3. app — the full path to the emulator build of the Salesforce app
    3. For iOS:
      1. In Appium Desktop, click the Edit icon in the JSON representation section and paste in the JSON below:
        1. {
          “platformName”: “iOS”,
          “deviceName”: “iPhone 11”,
          “platformVersion”: “13.6”,
          “app”: “/Users/dstead/Downloads/SalesforceApp-Simulator-226.010-iOS.zip”
          }
      2. Modify the following Desired Capabilities to match the simulator you want to execute on:
        1. deviceName — the name of the device to be simulated
        2. platformVersion — the version of iOS the simulator is running
        3. app — the full path to the simulator build of the Salesforce app
  6. Click the Start Session button in the bottom right hand side of the screen.

Now, if you have everything configured correctly, the simulator should start and open the Salesforce app!

You can now use Appium Desktop to inspect the Salesforce App UI and find the locators that you will need as you develop your automated tests. For instance, you can see that the accessibility ID of the “I Accept” button is EULA.agree:

Thanks to the new Salesforce mobile app emulator and simulator builds, and a testing framework like Appium, automated testing for mobile apps has become much more accessible to mobile app developers. Leverage tools like Appium and the Salesforce mobile app emulator to provide a higher quality product to your end users.

To learn more about automated testing at Salesforce, and specifically about mobile automated testing, head to the Test Automation Trailblazer Community where this discussion continues.

About the author

Dan Stead is a Lead Engineer at Salesforce where he focuses on enabling customer testing on the Salesforce Platform. He has over 10 years of test automation experience.

Stay up to date with the latest news from the Salesforce Developers Blog

Subscribe