我正在嘗試在Robotium中運行一些自動化測試。我在我的應用程序下面的代碼設置了一個選項菜單:單擊Robotium中的Action Bar菜單項
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
但是我的測試與錯誤失敗的原因:
solo.clickOnView(solo.getView(R.id.logoutmenu));
solo.clickOnMenuItem("Share My Artists");
:
View is null and therefore cannot be clicked.
我也用下面的代碼,這也沒試過
你在Android 2.3上運行你的測試嗎? – atermenji
@atermenji no on 4.1 – AndroidEnthusiast