diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEndPage.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEndPage.java index 98985c5c72a..725526acfa9 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEndPage.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEndPage.java @@ -24,9 +24,7 @@ public FormEndPage assertOnPage() { } public > D clickSaveAsDraft(D destination) { - return tryAgainOnFail(destination, () -> { - clickOnString(org.odk.collect.strings.R.string.save_as_draft); - }); + return clickOnString(org.odk.collect.strings.R.string.save_as_draft, destination); } public MainMenuPage clickSaveAsDraft() { @@ -34,9 +32,7 @@ public MainMenuPage clickSaveAsDraft() { } public > D clickFinalize(D destination) { - return tryAgainOnFail(destination, () -> { - clickOnString(org.odk.collect.strings.R.string.finalize); - }); + return clickOnString(org.odk.collect.strings.R.string.finalize, destination); } public MainMenuPage clickFinalize() { diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java index 81512c3bc89..7ae75db0bac 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java @@ -251,7 +251,7 @@ public FormEntryPage longPressOnQuestion(String question) { } public FormEntryPage longPressOnQuestion(String question, boolean isRequired) { - return tryAgainOnFail(this, () -> { + WaitFor.tryAgainOnFail(() -> { if (isRequired) { onView(withText("* " + question)).perform(longClick()); } else { @@ -260,6 +260,8 @@ public FormEntryPage longPressOnQuestion(String question, boolean isRequired) { assertText(org.odk.collect.strings.R.string.clear_answer); }); + + return this; } public FormEntryPage removeResponse() { diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt index 9611da484ae..7607d6c078c 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt @@ -238,6 +238,15 @@ abstract class Page> { return checkIsToastWithMessageDisplayed(getTranslatedString(id, *formatArgs)) } + fun > clickOnString(stringID: Int, destination: D): D { + tryAgainOnFail { + clickOnString(stringID) + destination.assertOnPage() + } + + return destination + } + fun clickOnString(stringID: Int): T { clickOnText(getTranslatedString(stringID)) return this as T