appium定位元素
一、常用识别元素的工具 uiautomator:Android SDK自带的一个工具,在tools目录下 monitor:Android SDK自带的一个工具,在tools目录下 Appium Inspector:Appium自带的一个功能,只有mac下可以使用该功能 下面是用monitor抓取到的页面元素 下面使用Appium Inspector定位的元素 二、元素定位 1.格式:find_element_by_定位方式(value) 通过id定位 (取resource-id的值): driver.find_element_by_id("com.wuba.zhuanzhuan:id/azo") 也可以直接用id后面的内容driver.find_element_by_id("azo") 通过class_name定位 (取class的内容) driver.find_element_by_class_name("android.widget.RelativeLayout") 通过xpath定位 (取xpath得内容) driver.find_element_by_xpath("//android.widget.LinearLayout[1]/android.widget.XXX") 通过text定位 (需要使用uiautomator的定位方式,使用text的内容) driver