From 96be7af533dee977b07268957f9d66bf78205598 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Tue, 5 Jul 2022 13:04:03 +0300 Subject: [PATCH] Fix and re-enable findInPageTest UI test --- .../mozilla/fenix/ui/NavigationToolbarTest.kt | 26 +++++++------------ .../fenix/ui/robots/FindInPageRobot.kt | 8 ++---- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt index 0fdaa1810..9a125dc22 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt @@ -9,7 +9,6 @@ import androidx.test.uiautomator.UiDevice import okhttp3.mockwebserver.MockWebServer import org.junit.After import org.junit.Before -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.mozilla.fenix.ext.settings @@ -108,17 +107,13 @@ class NavigationToolbarTest { } } - @Ignore("Temp disable broken test - see: https://github.com/mozilla-mobile/fenix/issues/5534") @Test fun findInPageTest() { - val loremIpsumWebPage = TestAssetHelper.getLoremIpsumAsset(mockWebServer) + val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 3) navigationToolbar { - }.enterURLAndEnterToBrowser(loremIpsumWebPage.url) { + }.enterURLAndEnterToBrowser(defaultWebPage.url) { mDevice.waitForIdle() - } - - navigationToolbar { }.openThreeDotMenu { verifyThreeDotMenuExists() verifyFindInPageButton() @@ -126,19 +121,18 @@ class NavigationToolbarTest { verifyFindInPageNextButton() verifyFindInPagePrevButton() verifyFindInPageCloseButton() - enterFindInPageQuery("lab") + enterFindInPageQuery("a") verifyFindNextInPageResult("1/3") + clickFindInPageNextButton() verifyFindNextInPageResult("2/3") + clickFindInPageNextButton() verifyFindNextInPageResult("3/3") - verifyFindPrevInPageResult("1/3") - verifyFindPrevInPageResult("3/3") + clickFindInPagePrevButton() verifyFindPrevInPageResult("2/3") - enterFindInPageQuery("in") - verifyFindNextInPageResult("3/7") - verifyFindNextInPageResult("4/7") - verifyFindNextInPageResult("5/7") - verifyFindNextInPageResult("6/7") - verifyFindNextInPageResult("7/7") + clickFindInPagePrevButton() + verifyFindPrevInPageResult("1/3") + enterFindInPageQuery("3") + verifyFindNextInPageResult("1/1") }.closeFindInPage { } } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/FindInPageRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/FindInPageRobot.kt index 9472a20a3..c800d3989 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/FindInPageRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/FindInPageRobot.kt @@ -33,6 +33,8 @@ class FindInPageRobot { fun verifyFindInPageNextButton() = assertFindInPageNextButton()!! fun verifyFindInPagePrevButton() = assertFindInPagePrevButton()!! fun verifyFindInPageCloseButton() = assertFindInPageCloseButton()!! + fun clickFindInPageNextButton() = findInPageNextButton().click() + fun clickFindInPagePrevButton() = findInPagePrevButton().click() fun verifyFindInPageSearchBarItems() { verifyFindInPageQuery() @@ -51,18 +53,12 @@ class FindInPageRobot { fun verifyFindNextInPageResult(ratioCounter: String) { mDevice.waitNotNull(Until.findObject(By.text(ratioCounter)), waitingTime) - val element = mDevice.findObject(By.text(ratioCounter)) findInPageResult().check(matches(withText((ratioCounter)))) - findInPageNextButton().click() - element.wait(Until.textNotEquals(ratioCounter), waitingTime) } fun verifyFindPrevInPageResult(ratioCounter: String) { mDevice.waitNotNull(Until.findObject(By.text(ratioCounter)), waitingTime) - val element = mDevice.findObject(By.text(ratioCounter)) findInPageResult().check(matches(withText((ratioCounter)))) - findInPagePrevButton().click() - element.wait(Until.textNotEquals(ratioCounter), waitingTime) } class Transition {