Appium is an open source test automation framework for mobile apps. It has the 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 in helping us to inspect the mobile elements in the recent IOS versions. Apple has stopped supporting UIAutomation in which iOS build taken from the XCODE 7.X. XCUITEST playing a major role to manage the UI Automation for the latest iOS application .APP build using XCODE 8.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 an perfect alternative for Appium Inspector in respect to IOS and Android Automation.
What is Macaca Inspector?
This is a slick web based inspector created by the Macaca team, that is from the mighty Alibaba Inc. Macaca basically provides a full suites 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 ANT path is set globally.
NPM command will only work if the NodeJS is installed on the system. Please go through the chapter How to Install NodeJS
1) On windows, Open up CMD and run “npm install macaca-cli -g“
Once the installation is complete, you will see the Successful message.
2) After install is complete, verify it was installed correctly, run “macaca doctor”
4) Next, run ”npm install app-inspector -g”
After install is complete you should see that the words “BUILD SUCCESSFUL” in the logs.
5) Connect the device or launch a simulator and grab the DEVICE_ID of the device or simulator by issuing “adb devices”. Please follow the tutorial to learn How to Connect with Android Device.
6) 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.
Note: For Android you can load any application via adb
- ” adb install example.apk“
- For simulator ” adb install -s example.apk “
7) 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 a 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.
I am ARJUN BM, Lead QA with good experience and knowledge in Automation and Manual Testing concepts. Over 6 year of testing experience in Mobile/Web and ERP Applications. Outstanding abilities to test web, mobile and Windows based applications. Good Knowledge about writing automation scripts using Selenium webdriver and QTP. Hands on experience on Keyword driven Automation Framework implementation and hybrid automation framework.