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

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

Courtney Zhan

--

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…

--

--

No responses yet