Appium is an open-source test automation framework for mobile apps. It has a similar concept as Selenium WebDriver. For iOS, underlayer, it uses Xcode’s instrument tool UIAutomation to drive the UI operation on the app.
Appium inspector is not great at helping us to inspect the mobile elements in the recent IOS versions. XCUITEST playing a major role to manage the UI Automation for the latest iOS application.APP build using XCODE 10.x.
This blog posting helps to Extract Xpath from App using Macaca Inspector, so you can inspect the mobile elements of Native, Hybrid and Mobile Web specific mobile/web elements using the open-source utility of Macaca inspector, which is a perfect alternative for Appium Inspector in respect to IOS and Android Automation.
What is Macaca Inspector?
Macaca is an open-source automation test solution for native, hybrid, mobile web and web applications on mobile and desktop platforms. This is a slick web-based inspector created by the Macaca team, that is from the mighty Alibaba Inc. Macaca basically provides a full suite of open source solutions based on Selenium WebDriver, for both Web and mobile. This inspector is just one of the tools.
The tool has the ability to pull Xpath values for Android or IOS.
How to Install Macaca Inspector?
These instructions are under the assumption you have Appium installed locally already with nodeJS, and Android and JAVA path is set globally.
To install app-inspector, Node.js environment is required. NPM command will only work if the NodeJS is installed on the system.
macaca-cli is recommended to install.
Once the installation is complete, you will see the Successful message.
Your environment needs to be setup for the particular mobile platforms that you want to view.
Refer to Macaca Environment Setup doc to install Android SDK for Android, Xcode for iOS.
Verify the environment with macaca-cli.
After install is complete, verify it was installed correctly, run “macaca doctor”
If you saw some green log information, it means your platform environment is ready. Then you can install app-inspector and use it.
Make sure that everything should be green. If anything is Red, you need to install that to your system such as JAVA_HOME, ANDROID_HOME etc.
Next, run ”npm install app-inspector -g”
After install is complete you should see that the words “BUILD SUCCESSFUL” in the logs.
Connect the device or launch a simulator and grab the DEVICE_ID of the device or simulator by issuing “adb devices” and for IOS “xcrun simctl list” -> You can find the UDID like XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
Copy the DEVICE_ID and then run,”app-inspector -u YOUR-DEVICE-ID” Make sure device or simulator is booted first before running. When the process is finished, it will load a new window with the view hierarchy loaded and BRAVO! you now have a app inspector. Then open the link http://192.168.10.100:5678 in your browser.
Now if you go back to the page that loaded the view hierarchy, hit refresh and the app view will load. If you click on an element in the view, it will highlight where that element corresponds to in the view like below:
OR You can select the element from the tree and it will highlight it on the view. On the right hand side you will see that it will also include the Xpath.
More info can be found here
Hope this helps to solve your automation problems. By the way, head over to my about page and get more details about me – https://testwitharjun.com/about/
Let me know in the comments of any other tools or if you have a different method i would love to hear it!