If the method given in Appium does not meet your needs, just as the method in Uiautomator can meet your needs, you can use Find_element_by_android_uiautomator to invoke the method in Uiautomator.
Appium The following instructions are given in the underlying file Webdriver:
def find_element_by_android_uiautomator (self, uia_string): """ Finds element by Uiautomator in Android. : Args: in the Android uiautomator library : Usage: driver.find_element_by_ Android_uiautomator ('. Elements () [1].cells () [2]') "" " return self.find_element (By=by.android_uiautomator, value=uia_string)
For a while, Leng did not understand the example of what the meaning of the actual script, how to use, I know that I am too stupid, so decisive or find can read the example of learning it, so haha also really found, this use of the way to write a simple example to record, explained: here has text for example, The method used in the rest of the uiautomator is consistent with this, so there is one sufficient to implement other requirements in this way.
Examples are as follows:
# coding=utf-8" "Created on2017.12. +@author: Lucky" " fromappium Import Webdriverclasscustomer:def __init__ (self): Logging.info ("Test_appium.....setup") desired_cups={} desired_cups['PlatformName'] ='Android'desired_cups['platformversion'] ='7.0'desired_cups['devicename'] ='AA'desired_cups['Apppackage']='Com.ibroker.iBerHK'desired_cups['appactivity'] ='. Splashactivity'Self.device= Webdriver. Remote ('Http://127.0.0.1:4723/wd/hub', Desired_cups) self.device.implicitly_wait ( -) #全局默认等待最大时间 #第一种 Direct Click String
def enter_customer_list (self):" "Select: Message recording into and hand adding" "Self.device. Find_element_by_android_uiautomator ('text (\ "list \")'). Click () #点击 string "list"
#第二种 manipulated by a given parameter
def enter_customer_list2 (self,name):
"SELECT: The message is recorded into and hand added" ' self.device. Find_element_by_android_uiautomator(' Text (\ ' +name+ ' \ ') '). Click ()
if __name__ = = "__main__":
c = Customer ()
C. Enter_customer_list ()
C.enter_customer_list (' list ')
Appium element Positioning Find_element_by_android_uiautomator method use