private void overFlowItemsCheck( int firstActivityName, int secondActivityName, int thirdActivityName) { openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext()); onView(withText(firstActivityName)).check(ViewAssertions.matches(isDisplayed())); onView(withText(secondActivityName)).check(ViewAssertions.matches(isDisplayed())); onView(withText(thirdActivityName)).check(ViewAssertions.matches(isDisplayed())); }
public void testOverflowMenuOrOptionsMenu() { // Open the action bar overflow or options menu (depending if the device has or not a hardware // menu button.) // openActionBarOverflowOrOptionsMenu(getInstrumentation().getContext()); openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext()); // Find the menu item with text "About" and click on it onView(withText("Settings")).perform(click()); // Verify the correct item was clicked by checking the content of the status TextView onView(withId(R.id.action_settings)).check(matches(withText("Settings"))); }
@Test public void openMenu() { /* Open ActionBar Menu*/ openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); onView(withText("Settings")).perform(click()); }
public void testClickOnMenuItem() { // Click on an item from ActionBar openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext()); // onView(withId(R.id.action_settings)).perform(click()); onView(withText(R.string.action_settings)).perform(click()); }
/** Convenience method which opens the options menu and select the take image option. */ private void selectTakeImageFromMenu() { openActionBarOverflowOrOptionsMenu(getTargetContext()); // Click on add picture option onView(withText(R.string.take_picture)).perform(click()); }