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
- Install Appium:
- Download and install Appium from Appiumās official website.
- Start Appium Server:
- Open the Appium Desktop and start the server.
- 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.
- 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
- Launch Appium Inspector: With the server running, open the Appium Inspector.
- Start a Session: Use the desired capabilities to start a session.
- Inspect Elements: Click on elements in the Appium Inspector to see their XPath and other attributes.