protected void closeKeyboard() { Espresso.closeSoftKeyboard(); }
@When("^I tap login button$") public void I_tap_login_button() { // Close the keyboard else the login button is not available for click on the screen Espresso.closeSoftKeyboard(); onView(withId(R.id.login)).perform(click()); }
/** * Clears the search query by pressing the X button * @param activity */ public static void clearSearchQueryXButton(Activity activity) { try { onView(withId(R.id.search_close_btn)).perform(click()); } catch (NoMatchingViewException e) { EspressoTestUtils.clickMenuItem(activity, activity.getString(R.string.action_search), R.id.action_search); onView(withId(R.id.search_close_btn)).perform(click()); } Espresso.closeSoftKeyboard(); }
/** * Tests if search query is still cleared when * device is rotated after switching to a different tab * * UI interaction flow tested: * 1. Enter search query * 2. Switch to Albums tab * 3. Rotate device * 4. Open search menu item * 5. Result: search query should be cleared */ @Test public void searchSwitchTabRotateTest() { Activity activity = mActivityRule.getActivity(); EspressoTestUtils.enterSearchQuery(activity, ARTIST_SEARCH_QUERY); clickAlbumsTab(); EspressoTestUtils.rotateDevice(activity); EspressoTestUtils.clickMenuItem(activity, activity.getString(R.string.action_search), R.id.action_search); Espresso.closeSoftKeyboard(); EspressoTestUtils.checkTextInSearchQuery(""); EspressoTestUtils.checkListMatchesSearchQuery("", ALBUM_COMPLETE_LIST_SIZE, R.id.list); }
@Test public void brushPickerDialogEditTextBehaviour() { onView(withId(R.id.pocketpaint_stroke_width_width_text)) .perform(replaceText(String.valueOf(MIDDLE_STROKE_WIDTH))); Espresso.closeSoftKeyboard(); onView(withId(R.id.pocketpaint_stroke_width_width_text)) .check(matches(withText(String.valueOf(MIDDLE_STROKE_WIDTH)))); onView(withId(R.id.pocketpaint_stroke_width_seek_bar)) .check(matches(withProgress(MIDDLE_STROKE_WIDTH))); } }
private void enterTextInput(final String textToEnter) { /* * Use replaceText instead of typeText to support the arabic input. * * See: * java.ic_pocketpaint_menu_language.RuntimeException: Failed to get key events for string السلام عليكم 123 (i.e. * current IME does not understand how to translate the string into key events). As a * workaround, you can use replaceText action to set the text directly in the EditText field. */ onView(withId(R.id.pocketpaint_text_tool_dialog_input_text)).perform(replaceText(textToEnter)); Espresso.closeSoftKeyboard(); onView(withId(R.id.pocketpaint_text_tool_dialog_input_text)).check(matches(withText(textToEnter))); }
public void editMetaDetails() { String passTitle = "EditedPassageTitle"; String passage = "EditedShort Passage."; onView(withId(R.id.template_meta_listview)).perform(longClick()); onView(withId(R.id.action_edit)).perform(click()); closeSoftKeyboard(); onView(withId(R.id.meta_title)).perform(replaceText(passTitle)); closeSoftKeyboard(); onView(withId(R.id.meta_passage)).perform(replaceText(passage), ViewActions.closeSoftKeyboard()); sleep(); onView(withResourceName("buttonDefaultPositive")).perform(click()); }
public void addQuestions() { String question = "This is just a silly question whose answer is (b)."; onView(withId(R.id.button_add_item)).perform(click()); onView(withId(R.id.quiz_question)).perform(typeText(question)); closeSoftKeyboard(); sleep(); onView(withId(R.id.quiz_option_1)).perform(scrollTo()); onView(withId(R.id.quiz_option_1)).perform(typeText("A")); closeSoftKeyboard(); sleep(); onView(withId(R.id.quiz_option_2)).perform(scrollTo()); onView(withId(R.id.quiz_option_2)).perform(typeText("B")); closeSoftKeyboard(); sleep(); onView(withId(R.id.quiz_radio_2)).perform(scrollTo()).perform(click()); closeSoftKeyboard(); sleep(); onView(withResourceName("buttonDefaultPositive")).perform(click()); }
public void editQuestions() { String question = "This is just a silly question whose answer changed to (a)."; onData(anything()).inAdapterView(withId(R.id.template_editor_listview)).atPosition(1).perform(longClick()); onView(withId(R.id.action_edit)).perform(click()); onView(withId(R.id.quiz_question)).perform(replaceText(question)); closeSoftKeyboard(); onView(withId(R.id.quiz_radio_1)).perform(scrollTo()).perform(click()); closeSoftKeyboard(); onView(withResourceName("buttonDefaultPositive")).perform(click()); }
public void addMetaDetails() { String passTitle = "PassageTitle"; String passage = "Short Passage."; String timer = "180"; onView(withId(R.id.button_add_item)).perform(click()); closeSoftKeyboard(); onView(withId(R.id.meta_title)).perform(typeText(passTitle)); closeSoftKeyboard(); onView(withId(R.id.meta_passage)).perform(typeText(passage), ViewActions.closeSoftKeyboard()); sleep(); onView(withId(R.id.meta_timer)).perform(scrollTo()); sleep(); onView(withId(R.id.meta_timer)).perform(click()).perform(typeText(timer), ViewActions.closeSoftKeyboard()); sleep(); onView(withResourceName("buttonDefaultPositive")).perform(click()); }