Skip to content

Commit

Permalink
Add retry click action
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Apr 8, 2024
1 parent 2b52f12 commit 7c29ae5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ public FormEndPage assertOnPage() {
}

public <D extends Page<D>> 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() {
return clickSaveAsDraft(new MainMenuPage());
}

public <D extends Page<D>> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ abstract class Page<T : Page<T>> {
return checkIsToastWithMessageDisplayed(getTranslatedString(id, *formatArgs))
}

fun <D : Page<D>> 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
Expand Down

0 comments on commit 7c29ae5

Please sign in to comment.