First introduce the two positioning elements of the tool, Appium with the Inspector and Android SDK comes with the Uiautomatorviewer1, Uiautomator Viewer is relatively simple, after the simulator opens the app, open it, select
Click this button to sync the emulator or the real-computer interface
Clicking on the element in the page will display some information about the element in the lower right corner.
2, Inspector (Android) use Inspector is more troublesome, first set Appium① first is Android setting
The first time the package and launch activity is not selected items can be empty, fill in application path②general settings check the following two
③ start Appium will find automatically installed APK, and then click on the Appium Search button, pop-up inspector window, click Refresh, refresh the Sync page, in the lower right corner will also display the element information
If an error occurs, check the Appium log for troubleshooting element Positioning method:①by_id
②by_class_name③by_nameIf the control you want to locate has text, you can try by_name directly, or you can use By_name if the text behind it has a value.④by_link_textIf the Herf link tag can be directly attempted with link positioning, but only for WebView, and web Automation is consistent⑤by_xpathFor example, locate the active button
FRAMELAYOUT/LISTVIEW/LINEARLAYOUT/GRIDVIEW/LINEARLAYOUT[1] This is the absolute path XPath XPath can write the first, take advantage of element attributes// Android.widget.textview[contains (@text, ' activity ')] the second kind, basically is to look at the element path, using index//android.widget.listview[0]/ android.widget.linearlayout[0]/android.widget.gridview/android.widget.linearlayout[0]/ Android.widget.TextView layer down analysis, if the same class appears according to index to locate, and the same as the XPath in the Web
appium--element Positioning