4

What is the correct way to open NavigationDrawer and select items from the navigation list in Robotium 5.1? I tried

solo.setNavigationDrawer(Solo.OPENED);

clickInList(position);

yet they're not working.

Community
  • 1
  • 1
Mahmoud Abou-Eita
  • 933
  • 1
  • 8
  • 17
  • Take a look at this: http://stackoverflow.com/a/23150545/1006570 – Smileek Apr 18 '14 at 08:52
  • Hi, This question has been answered here. http://stackoverflow.com/questions/26118480/how-to-open-navigation-drawer-menu-in-robotium-automation-script-in-android/29645959#29645959 – Ankit Apr 15 '15 at 09:02

2 Answers2

2

If you examine a navigation drawer activity with uiautomatorviewer you can notice that the navigation drawer menu button is the first ImageButton. So you can invoke the menu and press the first item through:

solo.clickOnImageButton(0); // open menu solo.sendKey(KeyEvent.KEYCODE_DPAD_DOWN); // select first item solo.sendKey(KeyEvent.KEYCODE_DPAD_CENTER); // press the first item

0

Try this solo.clickOnScreen(50, 50); I tried solo.clickOnActionBarHomeButton(); However sometimes it does not work. Also please refer this answer

Community
  • 1
  • 1
Yuchao Zhou
  • 1,062
  • 14
  • 19
  • please don't use hard coded coordinates...with many build servers and devices running tests that's a bad and unreliable way – isuPatches Jul 10 '15 at 14:06