How to open navigation drawer menu in Robotium aut

2019-08-12 02:52发布

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

5条回答
Animai°情兽
2楼-- · 2019-08-12 03:07

Finally I did it by using Navigation Drawer Name Ex solo.clickOnText("Home");

查看更多
不美不萌又怎样
3楼-- · 2019-08-12 03:08

You can use the following method to open the drawer using Robotium:

Solo solo = new Solo(getInstrumentation(), getActivity());
solo.setNavigationDrawer(Solo.OPENED);
查看更多
来,给爷笑一个
4楼-- · 2019-08-12 03:12

Method 1:

solo.clickOnImageButton(0);

or

Method 2:

solo.setNavigationDrawer(Solo.OPENED);
solo.clickOnActionBarHomeButton();

Both the Methods worked for me.

查看更多
三岁会撩人
5楼-- · 2019-08-12 03:16

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.

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-08-12 03:19

You can open navgation drawer using content description

driver.findElementByAccessibilityId("Open navigation drawer").click();
查看更多
登录 后发表回答