zoukankan      html  css  js  c++  java
  • 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 里面的一致):

    获取不到,但会显示在 uiautomatorviewer 中的属性:

    • index
    • package
    • password
    • bounds(可通过 get_position 来获取其中部分内容)
  • 相关阅读:
    从视频中每隔固定帧进行提取图片
    np.concatenate的超简单理解
    python-OOP(面向对象)
    机器学习中的ground truth
    深度学习网络中backbone是什么意思?
    缓存
    Linux基础命令
    openoffice相关命令
    HTTP协议
    Solr基础
  • 原文地址:https://www.cnblogs.com/yrxns/p/7910483.html
Copyright © 2011-2022 走看看