我是Robotium的新手。我使用对话框构建器创建了一个警告对话框,并使用show命令调用它。我可以使用Robotium默认触发'ok'按钮,我无法为'取消'按钮做同样的操作。由于对话框没有与id关联,我不确定如何获取按钮的id。这里是我的对话框如何选择哪个按钮在Robotium上单击以提醒对话框?
alertDialogBuilder
.setMessage("Please enter only numbers without any spaces")
.setCancelable(true)
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
代码我用来触发测试类中的“确定”按钮的代码是
solo.getCurrentActivity().runOnUiThread(new Runnable() {
public void run() {
solo.getCurrentActivity().getCurrentFocus().requestFocus();
}
});
this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
如何做同样的“取消”按钮?提前致谢。
ya。修好了。感谢Renas – 2012-05-16 01:06:07