问题
I have a application with navigation drawer i want to open the drawer menu in Robotium automation script.my application minimum Api level is 11 so i am using action bar sherlock for action bar implementation. Please guide me in right way
回答1:
none of the methods mentioned in documentation seem to work. Best option is to swipe rightwards
private void swipeToRight() {
Display display = solo.getCurrentActivity().getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
float xStart = 0 ;
float xEnd = width / 2;
solo.drag(xStart, xEnd, height / 2, height / 2, 1);
}
This will do this trick.
回答2:
You can use the following method to open the drawer using Robotium:
Solo solo = new Solo(getInstrumentation(), getActivity());
solo.setNavigationDrawer(Solo.OPENED);
回答3:
Method 1:
solo.clickOnImageButton(0);
or
Method 2:
solo.setNavigationDrawer(Solo.OPENED);
solo.clickOnActionBarHomeButton();
Both the Methods worked for me.
回答4:
Finally I did it by using Navigation Drawer Name Ex solo.clickOnText("Home");
回答5:
You can open navgation drawer using content description
driver.findElementByAccessibilityId("Open navigation drawer").click();
来源:https://stackoverflow.com/questions/26118480/how-to-open-navigation-drawer-menu-in-robotium-automation-script-in-android