app中元素定位是通过uiautomatorviewer来查看,这个是android sdk中自带的一个工具,可以在sdk家目录的tools下找到:

双击打开之后,点击第二个按钮即可把手机当前界面的元素下载下来:

左边是手机屏幕上的元素,右边是具体的元素,元素和appium(python)模块中的有点不对应,具体对应如下:

UIAutoMatorViewer appium模块
text find_element_by_name
resource-id find_element_by_id
class find_element_by_class_name
content-desc find_element_by_accessibility_id

这里class一般是不用的,其他3个元素看情况使用,有些元素没有的时候就可以使用其他元素

上面讲的都是native app元素定位方法,如果app中包含html5元素,这时候就不能这么定位了,得使用chrome来定位html5元素

在chrome中打开“更多工具” -> “开发者工具”,得到如下界面:

点击右侧第二个按钮,即可切换到手机模式,可以在左侧地址栏输入网址,使用右侧的第一个按钮在左侧定位元素

app测试自动化之定位元素的更多相关文章

  1. 多测师讲解自动化selenium___定位元素002___高级讲师肖sir

    高级自动化测试python+selenium教程手册 --高级讲师肖sir(Harm) 第 2 章8种定位方法 总结: selenium 的 webdriver 提供了八种基本的元素定位方法,前面六种 ...

  2. appium+python测试app使用相对坐标定位元素

    我们获取到的是绝对坐标,如果换一个屏幕分辨率不同的手机那这个坐标自然会发生变化,要实现不同手机均能实现点击同一控件自然要用到相对坐标了,具体方法如下: 1.获取当前空间的绝对坐标(x1,y1),开启指 ...

  3. app测试自动化操作方法之三

    首先导包: from appium.webdriver.common.touch_action import TouchAction #(导包指针定位滑动手势密码那个) #设置手势密码(前提是在设备上 ...

  4. app测试自动化之混合APP(之前的三篇为原生APP的操作)

    混合开发的App中,经常会有内嵌的H5页面:定位方法与原生APP不同,需要上下文切换 #获取所有上下文contexts=dr.contextsprint(contexts)#打印当前上下文(有点问题应 ...

  5. app测试自动化操作方法之一

    1.在输入框里输入字符 dr.find_element_by_android_uiautomator\ ( 'new UiSelector().text("邮箱或手机号")').s ...

  6. app测试自动化操作方法之二

    3.进行APP的滑动操作 方法一:#获取窗口大小def get_size(): size=dr.get_window_size() return size print(get_size())#向上滑动 ...

  7. app测试自动化之打开简书的登录界面,等待五秒后关闭

    from appium import webdriverfrom time import *desired_caps={ -----desired_caps为自定义变量名 'platformName' ...

  8. Appium+Python自动化 2 定位元素方式

    1.找到 Android SDK安装路径tools 下面的 uiautomatorviewer.bat,如下截图 2.点击uiautomatorviewer.bat进行启动,左上角一共四个按钮,作用分 ...

  9. app测试自动化之测试套框架构造之公共部分以及测试用例导包二

    封装的公共部分:commonfrom time import sleepdef com(dr): #点击backup dr.find_element_by_android_uiautomator\ ( ...

随机推荐

  1. 【POJ2778】DNA Sequence 【AC自动机,dp,矩阵快速幂】

    题意 题目给出m(m<=10)个仅仅由A,T,C,G组成的单词(单词长度不超过10),然后给出一个整数n(n<=2000000000),问你用这四个字母组成一个长度为n的长文本,有多少种组 ...

  2. [leetcode]339. Nested List Weight Sum嵌套列表加权和

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  3. [leetcode]76. Minimum Window Substring最小字符串窗口

    Given a string S and a string T, find the minimum window in S which will contain all the characters ...

  4. [leetcode]78. Subsets数组子集

    Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solut ...

  5. python--事务操作

    #coding=utf-8 import sys import MySQLdb class TransferMoney(object): def __init__(self,conn): self.c ...

  6. Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/jms/JMSContext

    参考链接 : https://blog.csdn.net/angus_Lucky/article/details/82811946?utm_source=blogxgwz7 org.springfra ...

  7. Django实现微信消息推送

    一 所需准备条件 微信公众号的分类 微信消息推送 公众号 已认证公众号 服务号 已认证服务号 企业号 基于:微信认证服务号 主动推送微信消息.前提:关注服务号环境:沙箱环境 沙箱环境地址: https ...

  8. tar --exclude排除指定目录打包

    ----before-upgrade./ --exclude=apache-tomcat-/logs --exclude=apache-tomcat-/work 注意,--exclude后面跟路径名称 ...

  9. Linux的top命令

    文章来自于长风破浪博主的内容,下面是该博客网址. https://www.cnblogs.com/dragonsuc/p/5512797.html 为了自己能多学习,多记忆,所以直接搬到了这里,希望小 ...

  10. etcd-v2第一集

    网站:https://github.com/coreos/etcd 一些观点:https://yq.aliyun.com/articles/11035 1.etcd是键值存储仓库,配置共享和服务发现2 ...