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. 回忆Partition算法及利用Partition进行快排

    一.Partiton算法 Partiton算法的主要内容就是随机选出一个数,将这个数作为中间数,将大于它的排在它右边,小于的排在左边(无序的). int partition (int arr[],in ...

  2. python note 06 编码方式

    1.有如下值li= [11,22,33,44,55,66,77,88,99,90],将所有大于 66 的值保存至字典的第一个key中,将小于 66 的值保存至第二个key的值中.即: {'k1': 大 ...

  3. EasyUI datagrid单元格文本超出显示省略号,鼠标移动到单元格显示文本

    nowrap : true;  是前提 $('#×××').datagrid({ nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取 }); 省略号样式: <sty ...

  4. 426. Convert Binary Search Tree to Sorted Doubly Linked List把bst变成双向链表

    [抄题]: Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right po ...

  5. Linux查看某个进程的线程

    线程是现代操作系统上进行并行执行的一个流行的编程方面的抽象概念.当一个程序内有多个线程被叉分出用以执行多个流时,这些线程就会在它们之间共享特定的资源(如,内存地址空间.打开的文件),以使叉分开销最小化 ...

  6. osg探究补充:osg数据加载原理(插件机制简介)

    前言 我们接着昨天的继续,昨天主要是讲解了DatabasePager类中的特定的成员变量以及run函数的第一部分,对所要请求加载的数据按照是否是网络数据进行分类加载模式.今天我们就看看数据是怎们加载到 ...

  7. service redis start

    注意:需在redis-server所在目录执行

  8. ABP框架系列之四十八:(Specifications-规范)

    Introduction Specification pattern is a particular software design pattern, whereby business rules c ...

  9. latex表格代码

     基本代码 \begin{table}[!h] \caption{Notations Used in Real-time Analysis.} \label{table:notation} \cent ...

  10. Authorization Security for Mongodb

    To keep security for the mongodb server, we can create an authorized machanism. db.createUser( { use ...