IOS-specific Actions and Options

RunCommand

Runs the given command on the agent.

Options: Repeat, WhenFails, Screenshot, WaitBefore, WaitAfter, OcrLang, CaseSensitive, Retry, Timeout, UseShell, UntilVisible, UntilInvisible

Example: RunCommand ā€œopenā€ ā€œcom.google.ios.youtubeā€
Description: Opens the 'Youtubeā€™ on IOSā€¦

Example: RunCommand ā€œcloseā€ ā€œcom.google.ios.youtubeā€
Description: Closes the ā€˜Youtubeā€™ on IOS.

Example: RunCommand ā€œopenā€ ā€œcom.apple.weatherā€
Description: Opens the ā€˜Weatherā€™ on IOS.

Example: 1. RunCommand ā€œopenā€ ā€œcom.facebook.Facebookā€
Description: Opens the ā€˜Facebookā€™ on IOS.

How to find the bundle ID of an application installed on IOS device?

Bundle IDs are unique identifiers for macOS or iOS applications. Every application has a bundle ID, and this ID is used to identify and manage the application. We use the bundle ID to open the application in the RunCommand action, as shown in the given examples.

Steps to follow:

  • Ensure that your device is connected to your Mac via USB.
  • Open the Console app on your Mac.
  • Launch the app on your iOS device for which you want to find the bundle ID.
  • In the Console app, search for either the name of the app or the phrase "Asked to bootstrap a new process with identity" in the log entries.
  • Find the bundle ID of the application in the search results.

com.google.ios.youtube
This bundle ID belongs to Googleā€™s YouTube application for iOS. Googleā€™s applications usually start with ā€œcom.googleā€ followed by the platform (in this case, ā€œiosā€) and the name of the application.

com.apple.weather
This bundle ID belongs to Appleā€™s Weather application. Appleā€™s own applications usually start with ā€œcom.appleā€ followed by the name of the application.

com.facebook.Facebook
com.facebook.Facebook is the bundle ID for the Facebook app on iOS and macOS devices. The format of this bundle ID indicates that it is developed by Facebook (now Meta), and the specific app is the Facebook application.

Example: In cases where an element cannot be found, we can use XPath to click as shown in the following example. We automate a YouTube search by clicking the YouTube icon using XPath, using a parameterized search icon, and entering the given search text into the search field via XPath.

  • RunCommand ā€œxpath-clickā€ ā€œ//XCUIElementTypeIcon[@name=ā€œYouTubeā€]ā€
  • Click Image {SearchIcon}
  • RunCommand ā€œxpath-clickā€ ā€œ(//XCUIElementTypeButton[@name=ā€œSearch YouTubeā€])[1]ā€
  • RunCommand ā€œxpath-writeā€ ā€œ//XCUIElementTypeOther[@name=ā€œid.yoodle.logoā€]/XCUIElementTypeOther&&testingā€
  • Click Text ā€œSearchā€
  • RunCommand ā€œcloseā€ ā€œcom.google.ios.youtubeā€

Description:

  • Click on the YouTube icon using the XPath //XCUIElementTypeIcon[@name="YouTube"].
  • Click on the {SearchIcon} parameter.
  • Click on the ā€œSearch YouTubeā€ button using the XPath (//XCUIElementTypeButton[@name="Search YouTube"])[1]
  • Write the term ā€œtestingā€ in the search input field identified by the XPath //XCUIElementTypeOther[@name="id.yoodle.logo"]/XCUIElementTypeOther.
  • Click the text ā€œSearchā€
  • Close the YouTube

How to find the XPath of elements on an iOS device connected to your Mac?

By following these steps, you can find the XPath of elements on an iOS device connected to your Mac using Appium for automated testing.

Using Appium for Automated Testing

  1. Install Appium:
  1. Start Appium Server:
  • Open the Appium Desktop and start the server.
  1. Connect to the iOS Device:
  • Ensure your iOS device is connected and recognized by your Mac.
  • In Appium, set up a new session with the desired capabilities for your iOS device.
  1. Use Appium Inspector:

How do I install Appium Inspector?

  • Launch the Appium Inspector. It allows you to interact with your app and inspect elements.
  • Select an element in your app to view its XPath and other attributes.

Example Desired Capabilities for Appium:

{
ā€œplatformNameā€: ā€œiOSā€,
ā€œplatformVersionā€: ā€œ14.4ā€, // Replace with your iOS version
ā€œdeviceNameā€: ā€œiPhone 12ā€, // Replace with your device name
ā€œappā€: ā€œ/path/to/your.appā€, // Replace with the path to your app
ā€œautomationNameā€: ā€œXCUITestā€
}

Finding XPath in Appium Inspector

  1. Launch Appium Inspector: With the server running, open the Appium Inspector.
  2. Start a Session: Use the desired capabilities to start a session.
  3. Inspect Elements: Click on elements in the Appium Inspector to see their XPath and other attributes.