The Agile Way

The Agile Way

Share this post

The Agile Way
The Agile Way
Basic Appium Automation: Part 2 — Using Locators (iOS)

Basic Appium Automation: Part 2 — Using Locators (iOS)

How To Use the Accessibility ID, Name, XPath and Class Name Locators in iOS

Courtney Zhan's avatar
Courtney Zhan
Jul 22, 2024
∙ Paid
1

Share this post

The Agile Way
The Agile Way
Basic Appium Automation: Part 2 — Using Locators (iOS)
Share

In Part 1, we covered the available locator types in Appium 2. In this article, let’s look at creating a sample script using a few different locator types.

Key Points

  • Using the Accessibility ID, Name, XPath and Class Name Locators in a sample iOS app

  • Using the find_element method to locate a single element

  • Using thefind_elements method to locate multiple elements with the same locator

Sample App

This article uses Appium’s Sample iOS Test App. This is available on Appium’s Github page as a sample app. Download and save the TestApp.app.zip file (leave it as an app.zip — do not unzip).

This TestApp contains a simple addition calculator, which we will use to try out the AccessibilityID, Name, XPath and Class locator types.

iOS Test App — Accessibility ID, Name, XPath, Class Locators

The Appium capabilities to start up the Appium session are:

app_file = File.join(File.dirname(__FILE__), "..", "..", "sample-apps", "TestApp.app.zip")
opts = {
  caps: {
    automationName: 'xcuitest',
    platformName: 'ios',
    platformVersion: '17.2', # match your Xcode Simulator's version
    deviceName: 'iPhone 15', # match your Xcode Simulator's version
    app: app_file
  },
  appium_lib: {
    server_url: "http://127.0.0.1:4723"
  },
}

driver = Appium::Driver.new(opts).start_driver

You can copy these into Appium Inspector as well:

The Sample App’s addition calculator component looks like this:

It is made up of four sections:

  1. First integer text field

  2. Second integer text field

  3. “Compute Sum” button

  4. Result text (“???” if Computer Sum button hasn’t been pressed yet).

I will do a simple 2 + 3 calculation.

Let’s look at each section one by one and identify some locators.

Keep reading with a 7-day free trial

Subscribe to The Agile Way to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Zhimin Zhan
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share