如何使用文本在appium中查找元素?

How to find element in appium using text?

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

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

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