Android Automation : How to inspect WebViews and get locators
|There are several ways to inspect and build locators of native components in android application – That can be used with a number of android automation tools . e.g Robotium , Appium etc. UIAutomatorviewer, Hierarchyviewer to name a few.
When question comes about WebViews , we have a limited number of options. So here a Step by step procedure to get locators/inspect web elements in an android application, using Google Chrome browser on PC.
1. Open an Emulator having android version 4.3+
2. Install the application to the Emulator and open the WebView that we want to inspect.
Please Note: The activity having WebView must be the front most one.
3. Open Google Chrome(30+) in PC and navigate to “chrome://inspect”.
4. Check “Discover USB devices”.
5. Wait a while ! Now you can see the WebView page getting listed under the device/Emulator name along with an inspect button.
6. Click on the inspect button and you will get the complete HTML code base of the particular WebView which is on the screen of the Emulator.
7. Build your Xpath etc according to the HTML code, on mousehovering tags you can see the respective elements getting highlighted in the application itself.
- Bring the auto Sync magic of Protractor to Selenium with Java - October 23, 2015
- Restarting Appium Server could improve various server freezing issues and may improve execution time - January 20, 2015
- Appium with iOS 8 and XCode 6 : What’s new? - November 5, 2014
- REST API automation testing using Apache HttpClient – The Approach - October 3, 2014
- An Overview of mobile application : Moving forward to automation - October 1, 2014
- An introduction to REST - September 29, 2014
- Run ChromeDriver with Chrome Driver Service to reduce script execution time significantly - September 26, 2014
- Selenium WebDriver – Get Cookies from an existing session and add those to a newly instantiated WebDriver browser instance. - September 26, 2014
- Simulate Copy Paste action using Java Robot and Clipboard class - September 26, 2014
- Android : How to test if Android Application has memory leaks - August 11, 2014