如何使用Appium Python实现获取元素特定属性值的操作?

2026-06-09 14:132阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计185个文字,预计阅读时间需要1分钟。

如何使用Appium Python实现获取元素特定属性值的操作?

使用`get_attribute()`获取元素属性,括号内应填写属性名。例如,查看appium源码,如果是获取resource-id,则填写`resourceId`。示例代码如下:

pythonself.driver.find_element(MobileBy.XPATH, //*[contains(@resource-id, 'followed_btn')]).get_attribute('resourceId')

使用get_attribute()获取元素属性,括号里应该填写什么?

如何使用Appium Python实现获取元素特定属性值的操作?

查看appium源码

如果是获取resource-id,填写resourceId

​​self.driver.find_element(MobileBy.XPATH, "//*[contains(@resource-id,'followed_btn')]").get_attribute('resourceId')​​

如果是获取text,填写text,不是name,这是不准确吗?

​​self.driver.find_element(MobileBy.XPATH, "//*[contains(@resource-id,'followed_btn')]").get_attribute('text')​​


待探索




本文共计185个文字,预计阅读时间需要1分钟。

如何使用Appium Python实现获取元素特定属性值的操作?

使用`get_attribute()`获取元素属性,括号内应填写属性名。例如,查看appium源码,如果是获取resource-id,则填写`resourceId`。示例代码如下:

pythonself.driver.find_element(MobileBy.XPATH, //*[contains(@resource-id, 'followed_btn')]).get_attribute('resourceId')

使用get_attribute()获取元素属性,括号里应该填写什么?

如何使用Appium Python实现获取元素特定属性值的操作?

查看appium源码

如果是获取resource-id,填写resourceId

​​self.driver.find_element(MobileBy.XPATH, "//*[contains(@resource-id,'followed_btn')]").get_attribute('resourceId')​​

如果是获取text,填写text,不是name,这是不准确吗?

​​self.driver.find_element(MobileBy.XPATH, "//*[contains(@resource-id,'followed_btn')]").get_attribute('text')​​


待探索