appium的get_attribute方法
转http://blog.csdn.net/bear_w/article/details/50330753
问题描述
当使用类似下面的代码获取元素的 content-desc 属性时,会报 NoSuchElement 错误:
# python
self.driver.find_element_by_id("id").get_attribute("content-desc")
但使用如下代码却能正常执行:
# python
self.driver.find_element_by_id("id").click()
很明显,这个错误原因不是找不到元素,而是 get_attribute 出问题。
总结
1、获取 content-desc 的方法为 get_attribute("name") ,而且还不能保证返回的一定是 content-desc (content-desc 为空时会返回 text 属性值)
2、get_attribute 方法不是我们在 uiautomatorviewer 看到的所有属性都能获取的(此处的名称均为使用 get_attribute 时使用的属性名称):
可获取的:
字符串类型:
- name(返回 content-desc 或 text)
- text(返回 text)
- className(返回 class,只有 API=>18 才能支持)
- resourceId(返回 resource-id,只有 API=>18 才能支持)
布尔类型(如果无特殊说明, get_attribute 里面使用的属性名称和 uiautomatorviewer 里面的一致):
- enabled
- checkable
- checked
- clickable
- focusable
- focused
- longClickable(返回 long-clickable)
- scrollable
- selected
- displayed(此元素是否在当前界面存在。调用的是 UIObject 的
exists()方法,详情请看http://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#exists())
获取不到,但会显示在 uiautomatorviewer 中的属性:
- index
- package
- password
- bounds(可通过 get_position 来获取其中部分内容)
appium的get_attribute方法的更多相关文章
- 关于 appium get_attribute 方法的坑
(得要学着看源码) 问题: self.driver.find_element_by_id("id").get_attribute("content-desc") ...
- Python Appium 元素定位方法简单介绍
Python Appium 元素定位 常用的八种定位方法(与selenium通用) # id定位 driver.find_element_by_id() # name定位 driver.find_ ...
- appium 元素定位方法汇总
以上图为例,要定位到右下角的 我的 ,并点击 # appium的webdriver提供了11种元素定位方法,在selenium的基础上扩展了三个,可以在pycharm里面输入driver.find_e ...
- Appium + python - get_attribute获取value操作
from appium import webdriverfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.w ...
- Python+Appium 查找 toast 方法的封装
使用场景:在操作应用时常见toast弹框,通过toast弹框信息的获取判断当前的某个操作是否成功 引用的包:from selenium.webdriver.support import expecte ...
- appium获取toast方法
配置toast请注意: 1.指定desired_caps["automationName"] = "UiAutomator2" 2.要求安装jdk1.8 64位 ...
- Appium + java截图方法
public static void takeScreenShot(AndroidDriver<WebElement> driver) { File screenShotFile = dr ...
- Appium处理滑动方法是swipe
滑动API:Swipe(int start x,int start y,int end x,int y,duration) 解释: int start x-开始滑动的x坐标:int start y - ...
- appium 使用send_keys方法时报错: driver.find_element_by_id("com.hmkx.zgjkj:id/layout_search_bar_input").send_keys("123")
新手 使用send_keys方法时一直报错,上网查这个方法的用法,看着大家都是这么写的啊,后来直接搜索 报错信息,搜索结果的针对性就清楚多了. 原来是seleium版本太高导致的问题. 可以先在cmd ...
随机推荐
- CSU1350 To Add which?
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1350 这题目因为每一个数都跟相邻的数有关,所以可以从左到右和从右到左一次扫一遍即可 代 ...
- JS把数字金额转换成中文大写数字的函数
//把数字金额转换成中文大写数字的函数 function num2rmb ($num){ $c1="零壹贰叁肆伍陆柒捌玖"; $c2="分角元拾佰仟万拾佰仟亿" ...
- PAT (Advanced Level) 1039. Course List for Student (25)
map会超时,二分吧... #include<iostream> #include<cstring> #include<cmath> #include<alg ...
- ArrayList和LinkedList区别(蚂蚁金服面试题)
1. 是否保证线程安全: ArrayList 和 LinkedList 都是不同步的,也就是不保证线程安全: 2. 底层数据结构: Arraylist 底层使用的是Object数组:LinkedLis ...
- java内存区域和对象的产生
一直被java中内存组成弄的头晕眼花,这里总结下都有哪些,先上图片 程序计数器 小块内存,线程执行字节码的信号指示器,以此获取下一条需要执行的字节码指令,分支,循环,跳转,异常处理,线程恢复都要依赖他 ...
- ARM PPC 交叉编译环境搭建
ARM: 1,下载cross-3.4.1.tar.bz2 2,在/usr/local目录下建立arm目录 3,将cross-3.4.1.tar.bz2拷贝到arm目录下 4,tar jxvf cros ...
- 携程Apollo(阿波罗)配置中心Spring Boot迁移日志组件,使用配置中心进行管理的思路
说明: 1.Spring Boot项目默认使用logback进行日志管理 2.logback在启动时默认会自动检查是否有logback.xml文件,如果有时会有限加载这个文件. 3.那么如果是用配置中 ...
- iOS: 解决Asset Catalog Compile Error - TDDIstiller instance can only be distilled only one time的错误
执行命令:rm -rf /Users/<用户名>/Library/Developer/Xcode/DerivedData 然后重新编译项目即可.
- HUNT:一款可提升漏洞扫描能力的BurpSuite漏洞扫描插件
今天给大家介绍的是一款BurpSuite插件,这款插件名叫HUNT.它不仅可以识别指定漏洞类型的常见攻击参数,而且还可以在BurpSuite中组织测试方法. HUNT Scanner(hunt_sca ...
- windows下 sqlplus / as sysdba 报ora-12560的终极解决方法
windows下 sqlplus / as sysdba 报ora-12560的终极解决方法 本文是原创文章.转载请注明出处:http://blog.csdn.net/msdnchina/articl ...