https://www.cnblogs.com/rabbit-testing/p/8042733.html 大牛

https://blog.csdn.net/kaka1121/article/details/53301517 大牛

ID定位

# resourceId属性的方法
driver.find_element_by_id('com.lizi.app:id/setting_imageView').click()
#以accessibility_id进行定位,对Android而言,就是content-description属性
driver.find_element_by_accessibility_id('push_button').click()

ClassName 定位

# 定位唯一元素  
self.driver.find_element_by_class_name("android.widget.EditText")
# 找到所有android.widget.EditText并定位第一个
self.driver.find_elements_by_class_name("android.widget.EditText")[0]

Name 定位

#根据name进行定位,对于android来说,就是text属性
driver.find_element_by_name(u"登 录").click() 

 Xpath 定位

driver.find_elements_by_xpath('//android.widget.TextView[@resource-id="com.mzdk.app:id/item_good_title"]')[1].click()

Uiautomator 定位

  • text属性的方法

driver.find_element_by_android_uiautomator('new UiSelector().text("Custom View")').click()         #text
driver.find_element_by_android_uiautomator('new UiSelector().textContains("View")').click() #textContains
driver.find_element_by_android_uiautomator('new UiSelector().textStartsWith("Custom")').click() #textStartsWith
driver.find_element_by_android_uiautomator('new UiSelector().textMatches("^Custom.*")').click() #textMatches
  • class属性的方法
#className
driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.TextView").text("Custom View")').click()
#classNameMatches
driver.find_element_by_android_uiautomator('new UiSelector().classNameMatches(".*TextView$").text("Custom View")').click()
  •  resourceId属性的方法
#resourceId
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("android:id/text1")')
#resourceIdMatches
driver.find_element_by_android_uiautomator('new UiSelector().resourceIdMatches(".*id/text1$")')
  •  元素的其他属性
driver.find_element_by_android_uiautomator('new UiSelector().clickable(true).text("Custom View")').click() 

Appium+Python 自动化-appium常用元素定位方法的更多相关文章

  1. 基于appium的常用元素定位方法

    一.元素定位工具 app应用的元素使用的是控件定位,不同于web网页,web网页定位元素通常使用的是F12工具,那么在app当中我们则要借助其它的工具来辅助定位. 1.uiautomatorviewe ...

  2. Robotframework + Appium 之常用元素定位方法

    任何自动化测试,其实手动测试也是一样的,元素定位(目标定位)是首要任务,这是最直接的测试对象呀! 好了,废话不多说,又到了元素定位啦,之前我们已经介绍过selenium及appium常用的定位方法,下 ...

  3. [python爬虫] Selenium常见元素定位方法和操作的学习介绍(转载)

    转载地址:[python爬虫] Selenium常见元素定位方法和操作的学习介绍 一. 定位元素方法 官网地址:http://selenium-python.readthedocs.org/locat ...

  4. Appium+python自动化-查看app元素属性

    本文转自:https://www.cnblogs.com/yoyoketang/p/7581831.html 前言 学UI自动化首先就是定位页面元素,玩过android版的appium小伙伴应该都知道 ...

  5. Selenium2+python自动化-八种元素定位(Firebug和Firepath)

    前言    自动化只要掌握四步操作:获取元素,操作元素,获取返回结果,断言(返回结果与期望结果是否一致),最后自动出测试报告.本篇主要讲如何用firefox辅助工具进行元素定位.元素定位在这四个环节中 ...

  6. python+Appium自动化:各种元素定位方法

    name定位 driver.find_element_by_name('飞利浦净水').click() 测试结果报错:selenium.common.exceptions.InvalidSelecto ...

  7. Appium+python自动化3-定位元素

    3.1常用定位方法讲解 对象定位是自动化测试中很关键的一步,也可以说是最关键的一步,毕竟你对象都没定位那么你想操作也不行.所以本章节的知识我希望大家多动手去操作,不要仅仅只是书本上的知识,毕竟这个我只 ...

  8. appium+python自动化34-获取元素属性get_attribute

    获取text # coding:utf-8 from appium import webdriver from time import sleep desired_caps = { 'platform ...

  9. [python爬虫] Selenium常见元素定位方法和操作的学习介绍

    这篇文章主要Selenium+Python自动测试或爬虫中的常见定位方法.鼠标操作.键盘操作介绍,希望该篇基础性文章对你有所帮助,如果有错误或不足之处,请海涵~同时CSDN总是屏蔽这篇文章,再加上最近 ...

  10. selenium python (二) 元素定位方法

    定位的原则就是:id name class 优先,强烈建议和前端哥哥搞好关系.定位就不是问题:实在不行就xpath和css大部分偶可以定位到. webdriver定位的方法是通过一个By类,By类中有 ...

随机推荐

  1. Linux 里的 2>&1含义

    我们在Linux下经常会碰到nohup command>/dev/null 2>&1 &这样形式的命令.首先我们把这条命令大概分解下: 首先就是一个nohup:表示当前用户 ...

  2. [leetcode]53. Maximum Subarray最大子数组和

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has ...

  3. pythonj基础(五)元组和集合

    一,什么是元祖 Python的元组与列表类似,不同之处在于元组的元素不能修改. 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. 1.创建一个空元组 tu ...

  4. 使用jmail发送短信

    原文链接 https://blog.csdn.net/sdaujsj1/article/details/79248469 pom <!-- https://mvnrepository.com/a ...

  5. 关闭浏览器时提示的javascript事件

    onbeforeunload事件 它是这样用的: <script language="javascript"> g_blnCheckUnload = true; fun ...

  6. SQL学习(一.索引)

    数据库索引 作用: 提高查询速度 确保数据的唯一性 可以加速表和表之间的连接,实现表和表之间的参照完整性 使用分组和排序子句进行数据检索时,可以减少分组和排序的时间 全文检索字段进行搜素优化 分类: ...

  7. Hbase 性能改进

    第一种性能改进方式:

  8. vue里router-link标签设置动态路由的3个方法

    1.to绑定data里面的一个值 2.to绑定一个对象,用name 3.to绑定一个对象,用path 例子: <router-link :to="home"><s ...

  9. k-th smallest 问题总结

    k-th smallest/biggest 问题大约有这几道: 373. Find K Pairs with Smallest Sums 从两个list里各取一个数求和,求所有可能的sum里第k小的 ...

  10. MySQL 查看修改字符集

    查看MYSQL数据库服务器和数据库字符集 方法一:show variables like '%character%'; 方法二:show variables like 'collation%'; sh ...