How to open navigation drawer menu in Robotium automation script in android

匆匆过客 提交于 2019-12-11 11:28:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!