Appium element Positioning Find_element_by_android_uiautomator method use

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.