【问题标题】:How to find element in appium using text?如何使用文本在 appium 中查找元素?
【发布时间】:2020-03-01 12:46:43
【问题描述】:

我想点击网站上的按钮。是否有代码可以让我使用 TEXT 字段单击元素?我既不能使用资源 id 字段也不能使用名称,因为它们是空的。我尝试使用 xpath 单击元素,但没有成功。

【问题讨论】:

  • 哪个设备的操作系统,Android 还是 iOS?
  • @Vault23 这是一个安卓设备

标签: python-3.x automation appium


【解决方案1】:

这是使用 Java 的示例,但我相信将它迁移到 Python 非常容易。 您需要使用 AndroidUiAutomator

androidDriver.findElementByAndroidUIAutomator("new UiSelector().text(\"your_text\")").click();

【讨论】:

  • 试过这个解决方案,但它说“搜索没有成功==='WebDriver'对象没有属性'find_element_by_android_uiautomator'”
  • 这不是属性,这是一种方法。在此处粘贴您的搜索代码
  • self.driver.find_element_by_android_uiautomator('new UiSelector().text("Submit")')
  • 你试过这个吗? driver.find_elements_by_xpath("//*[contains(text(), 'Submit')]")
  • 非常感谢。现在它正在工作。曾尝试使用绝对和相对 xpath,但不是这样。谢谢。
猜你喜欢
  • 2015-05-03
  • 1970-01-01
  • 1970-01-01
  • 2020-04-25
  • 1970-01-01
  • 2014-10-27
  • 2019-07-04
  • 2018-05-20
  • 2019-12-18
相关资源
最近更新 更多