【发布时间】:2017-03-27 19:36:42
【问题描述】:
我正在尝试在 Robotium 中运行一些自动化测试。我的应用程序中有以下代码,它设置了一个选项菜单:
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.layout.logoutmenu, menu);
return super.onCreateOptionsMenu(menu);
}
我尝试使用代码点击 Robotium 中的菜单:
solo.sendKey(Solo.MENU);
solo.clickOnView(solo.getView(R.id.share)); //share is the id of the menu item
但是我的测试因错误而失败:
View is null and therefore cannot be clicked.
我也尝试过使用下面的代码,但也失败了:
solo.clickOnView(solo.getView(R.id.logoutmenu));
solo.clickOnMenuItem("Share My Artists");
【问题讨论】:
-
你是在 Android 2.3 上运行你的测试吗?
标签: android actionbarsherlock robotium