UIAutomator元素定位是 Android 系统原生支持的定位方式,虽然与 xpath 类似,但比它更加好用,且支持元素全部属性定位.定位原理是通过android 自带的android uiautomator的类库去查找元素。 Appium元素定位方法其实也是基于Uiautomator来进行封装的。

使用方法 find_element_by_android_uiautomator() 可以运用UiAutomator元素定位。

定位方法

  • id定位
  • text定位
  • class name定位

id定位

id定位是根据元素的resource-id属性来进行定位,使用 UiSelector().resourceId()方法即可。

by_Uiautomator.py

from find_element.capability import driver

driver.find_element_by_android_uiautomator\

('new UiSelector().resourceId("com.tal.kaoyan:id/login_email_edittext")').send_keys('zxw1234')

driver.find_element_by_android_uiautomator\

('new UiSelector().resourceId("com.tal.kaoyan:id/login_password_edittext")').send_keys('zxw123456')

driver.find_element_by_android_uiautomator\

('new UiSelector().resourceId("com.tal.kaoyan:id/login_login_btn")').click()

text定位

text定位就是根据元素的text属性值来进行定位,new UiSelector()

driver.find_element_by_android_uiautomator\

('new UiSelector().text("请输入用户名")').send_keys('zxw1234')

class name定位

与Appium class定位方式一样,也是根据元素的class属性来进行定位。

driver.find_element_by_android_uiautomator\

('new UiSelector().className("android.widget.EditText")').send_keys('zxw1234')

UIAutomator定位简介的更多相关文章

  1. Appium之uiautomator定位元素

    元素定位方式有多种,Android也有自身独有的定位方式.下面就单独介绍其基于uiautomator定位元素的方法: 基本语法: driver.find_element_by_android_uiau ...

  2. UIAutomator定位Android控件的方法

    UIAutomator各种控件定位的方法. 1. 背景 使用SDK自带的NotePad应用,尝试去获得在NotesList那个Activity里的Menu Options上面的那个Add note菜单 ...

  3. 【转】UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)

    原文地址:http://blog.csdn.net/zhubaitian/article/details/39777951 在本人之前的一篇文章<<Appium基于安卓的各种FindEle ...

  4. UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)

    在本人之前的一篇文章<<Appium基于安卓的各种FindElement的控件定位方法实践和建议>>第二章节谈到Appium可以通过使用UIAutomator的方法去定位And ...

  5. 【appium】根据UIAutomator定位元素

    text属性的方法 driver.find_element_by_android_uiautomator('new UiSelector().text("Custom View") ...

  6. HTML定位简介

    转载出处 定位一直是WEB标准应用中的难点,如果理不清楚定位那么可能应实现的效果实现不了,实现了的效果可能会走样.如果理清了定位的原理,那定位会让网页实现的更加完美. 定位的定义:在CSS中关于定位的 ...

  7. appium python中的android uiautomator定位

    text定位:driver.find_element_by_android_uiautomator('new UiSelector().text("请输入手机号")') #模糊定位 ...

  8. Android UIAutomator 定位

    AndroidUIAutomator:Android的源生测试框架的定位方式,定位速度快 一.组合定位 1.一般组合用id,class,text这三个属性会比较好一点,但也可以组合定位 2.id与te ...

  9. 【appium】根据UIAutomator定位元素等等资料

    https://www.cnblogs.com/paulwinflo/p/4742529.html http://www.cnblogs.com/meitian/p/6103391.html http ...

随机推荐

  1. SpringMVC项目

    一.说明该项目是为了演示SpringMVC框架中涉及到的一些知识点,相对独立,掌握这些,基本上就能够解决工作中遇到的一些问题.整个项目的构建规划如下: 1.创建一个标准的Maven Web项目;2.使 ...

  2. HTML5:判断浏览器是否支持date类型

    在某些情况下,我们需要判断当前浏览器是否支持date类型,如果支持的话,可以让用户用原生的datepicker来选取日期.如果不支持,则我们需要用自己实现的datepicker类库,来提供给用户. 在 ...

  3. HDU 4509

    很简单的排序题而已. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  4. 大神note3千元指纹机,这是要逼疯友商吗

    新发现(光山居士).7月20日下午.奇酷公司在北京奥雅会展中心召开公布会,宣布推出首款千元级别的指纹识别机大神Note3.据悉.该型号手机.移动版售价899元.全网通版售1099元,并在16:00開始 ...

  5. [Vue] Lazy Load a Route by using the Dynamic Import in Vue.js

    By default, vue-router doesn’t lazy load the routes unless you tell it to do it. Lazy loading of the ...

  6. HDU 5294 Tricks Device(多校2015 最大流+最短路啊)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5294 Problem Description Innocent Wu follows Dumb Zha ...

  7. pcm数据生成wav文件

    Qt由pcm数据生成wav文件 void AudioGrabber::saveWave(const QString &fileName, const QByteArray &raw, ...

  8. 【iOS】网络载入图片缓存与SDWebImage

    载入网络图片能够说是网络应用中必备的.假设单纯的去下载图片,而不去做多线程.缓存等技术去优化,载入图片时的效果与用户体验就会非常差. 一.自己实现载入图片的方法 tips: *iOS中全部网络訪问都是 ...

  9. hive学习路线

    hive学习路线图:

  10. machine learning in coding(python):使用贪心搜索【进行特征选择】

    print "Performing greedy feature selection..." score_hist = [] N = 10 good_features = set( ...