【问题标题】:How to tap on UI element which does not have Text or content Description using Android UI Automator Viewer?如何使用 Android UI Automator Viewer 点击没有文本或内容描述的 UI 元素?
【发布时间】:2019-04-09 17:21:30
【问题描述】:

我目前正在使用 Android UI Automator 查看器。我想点击没有文字或内容描述的按钮,如何点击按钮?

【问题讨论】:

  • 嗨,欢迎来到堆栈溢出。请添加您的工作,以便我们更轻松地提供帮助

标签: android ui-automation android-uiautomator


【解决方案1】:

在能够点击按钮之前,您需要确保您的测试设置正确。如果您还没有这样做,我建议您查看this sample by Google,除了两个测试之外,您几乎可以复制所有内容。确保将包名称从他们的 com.example.android.testing.uiautomator.BasicSample 更改为您的包名称。

只要您的布局中有按钮的 id,您就应该能够点击它。

UiObject2 button = mDevice.findObject(By.res(BASIC_SAMPLE_PACKAGE, "your_button_id"));
button.click();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    • 2019-05-24
    • 2013-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多