【发布时间】:2019-04-09 17:21:30
【问题描述】:
我目前正在使用 Android UI Automator 查看器。我想点击没有文字或内容描述的按钮,如何点击按钮?
【问题讨论】:
-
嗨,欢迎来到堆栈溢出。请添加您的工作,以便我们更轻松地提供帮助
标签: android ui-automation android-uiautomator
我目前正在使用 Android UI Automator 查看器。我想点击没有文字或内容描述的按钮,如何点击按钮?
【问题讨论】:
标签: android ui-automation android-uiautomator
在能够点击按钮之前,您需要确保您的测试设置正确。如果您还没有这样做,我建议您查看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();
【讨论】: