当我尝试与蓝牙设备配对时,出现带有PIN的系统确认对话框。有“取消”和“确定”两个按钮。但我不能用Robotium点击它们。如何在Robotium中使用Android OS对话框?谢谢。
发布于 2013-09-28 01:19:57
这对我来说很有效:
solo.clickOnView(solo.getView(android.R.id.button1));
其中“正”按钮为android.R.id.button1,“负”按钮为android.R.id.button2,“中性”为android.R.id.button3。
发布于 2013-08-16 14:54:53
编写跨越两个应用程序的测试用例是不可能的。但是,如果它是同一应用程序的一部分,那么您可以使用solo.clickOnText("Cancel")
。同样,您也可以通过单击其他按钮的texts来单击它们。
发布于 2016-04-27 09:04:30
当涉及到Android系统对话框按钮时,Robotium可能会很困难,但是有一个解决方案。
Found the answer on this post on stack
// Set this dependency in your app's gradle file
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
并在您的测试项目中使用以下代码片段:
// Initialize UiDevice instance
UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
// Search for correct button in the dialog.
UiObject button = uiDevice.findObject(new UiSelector().text("ButtonTest"));
if (button.waitForExists(5000)) {
button.click();
}
https://stackoverflow.com/questions/18257104
复制相似问题