我正在尝试在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中的菜单:@H_301_5@
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 4.0上运行Robotium测试,请考虑使用solo.clickOnActionBarItem().