When testing native mobile apps on mobile simulator/emulator/ device,identifying the element locator is very important. We can use Selendroid Inspectors to view element definition and its hierarchy.
Selendroid Inspector is a ittle web app that is embedded inside your selendroid test server. It allows you to inspect the current state of your mobile app’s UI.
In this article, you will learn how to use the Selendroid Inspector to view a mobile app elements and run the test. You can find the tutorial on this site location (http://selendroid.io/inspector.html).
Important: Selenium mobile app test requires that android-sdk must be installed and configured properly on your computer, so you need to make sure that android-sdk environment was setup on your computer in advance. If you need help, please visit the site http://selendroid.io/setup.html.
Step 1: download Selendroid jar file and test mobile app.
navigate to Selendroid.io (http://selendroid.io) and download the two files.
open a windows command window and run the following command. If you want to repeat the test, it is better to write a DOS batch file and add the command below, so you can start the Selendroid server by clicking on the batch file.
You can check that the application(s) and the devices are recognized by opening a browser and navigating to: http://localhost:4444/wd/hub/status.
In your Selendroid Mobile App test project, add the selendroid-standalone-0.9.0-with-dependencies.jar, and other java libraries in the build path as external jar references.
Step 5: add a JUnit test class named MobileAppTest.java and add the following code below.
Step 7: run the JUnit test in Debug mode. In java, you open the debug perspective and run it as debug mode.
Step 8: open a web browser and type in the Selendroid Inspector Url . In the inspector browser window, you can see the app element hierarchy and element ids. Here is the screenshot of the element id "my_text_field".
Step 9: continue on the next line in the debug mode. The code types in "Selendroid" in the "my_text_field" element. See the screenshot below.
Step 10: continue on the next line. The test is done and JUnit test passed.
If you have other mobile apps, you can follow the steps above to identify app elements and test its functionality.