(Iv) Appium a targeting element

1. Open the Python editor, create a new python file, all Python scripts must be configured desired_caps, as shown below

desired_caps is a dictionary definition of the beginning of an empty dictionary, and then according to the key value, a plurality of parameters, these parameters constitute a dictionary. Set the parameters in order to connect the corresponding device APK, to process the request.

appium on windows is a server, after the start, if it is the first time you run the above script, appium two software will be installed on your phone, one is Appium Settings, a unlock. Appium Settings is a client-side, responsible for appium command interpretation and execution of the Windows side, used to wake up and unlock just a phone screen unlock function.

 

As shown above, start the desktop, the desktop at this time has been restarted once.

2.class positioning

Format: driver.find_element_by_class_name ( "class properties")

Get clock positioning element, as shown below, using the class name to locate the clock

Script can be run directly off the clock, and switches to the alarm interface as follows:

3.resource-id localization

格式:driver.find_element_by_id("resource-id")

To obtain the desired positioning of elements id, as shown below to navigate to the World Time icon, id world time is: com.android.deskclock: id / cities_button:

Click make a world of operating time, the code is as follows:

Run this script, it will switch to the World Clock screen.

4..accessibility_id positioning

Format: driver.find_element_by_accessibility_id ( "value of the content-desc")

 

 Locate the World Time icon, use accessibility_id positioning, first get content-desc attribute value of the element, as shown below:

 

Click make a world of operating time, the code is as follows:

The coordinate positioning

格式:driver.tap([(374, 831), (654, 906)], 500) 500是点击时间 tap是模拟点击

 

以上都是常用的定位方法,还有android_uiautomator定位方法和Xpath定位方法,一般脚本都是要先定位到该元素,才能对这个元素做操作.

 

Guess you like

Origin www.cnblogs.com/xiongxiaoyan/p/11272352.html