1 appium elements acquired skills
# Is the page slide driver.swipe (x1, y1, x1, y2, t) # get all the elements related with the label is actually a list of driver.find_elements_by_class_name ( ' android.widget.TextView ' ) # get the data and in accordance with the subscript click driver.find_elements_by_class_name ( ' android.widget.TextView ' ) [0] .click () # layer and the positioning Element = Driver. find_element_by_class_name ( ' android.support.v4.view.ViewPager ' ) Print (Element) Element = Element. find_element_by_class_name ( ' android.view.View ' ) Print(Element) Element = element.find_element_by_class_name ( ' android.widget.TextView ' ) element.click () # Note plurality of elements when positioned in a hierarchy, you can use subscripts to precise positioning
# UIAutomator positioned directly see the elements ui interface DEF into_by_uiautomator (): driver.find_element_by_android_uiautomator ( ' . New new UiSelector () text ( "immediate access to experience") ' ) .click () # Empty input box data driver.find_element_by_android_uiautomator ( ' new new UiSelector (). text ( "18,513,199,586") ' ) .clear () # to enter data into the input box driver.find_element_by_android_uiautomator ( ' new new UiSelector (). text ( "phone number / email") ' ) .send_keys ( ' 18513199587 ' ) # Note brackets can be replaced by text index, resource-id, class- name
# X_path # lookup directory that contains the entire label text driver.find_element_by_xpath ( ' // * [the contains (@Text, "login")] ' ) .click () # by child nodes driver.find_element_by_xpath ( ' // Android. widget.TextView [@ Resource-ID = "cn.com.open.mooc: ID / login_lable"] /../ PRECEDING-sibling :: android.widget.RelativeLayout ' ) .send_keys ( ' 123123 ' )
#tost from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC def get_tost(): time.sleep(2) driver.find_element_by_id('cn.com.open.mooc:id/account_edit').send_keys('18513199586') tost_element = ("xpath","//*[contains(@text,'请输入密码')]") WebDriverWait(driver,10,0.1).until(EC.presence_of_element_located(tost_element))
2 python reads the configuration file
Import OS from ConfigParser Import the ConfigParser read_ini = the ConfigParser () # get file path profile Print (the os.path.join (the os.path.join (os.path.dirname (The os.getcwd ()), ' config ' ), ' LocalElement.ini ' )) # read the configuration file read_ini.read (the os.path.join (the os.path.join (os.path.dirname (The os.getcwd ()), ' config ' ), ' LocalElement.ini ' ) ) # read data Print (read_ini.get ( ' login_element ' ,'username'))