From 3f211fe90b2d360a5f3c4ecc03cb5e4435ae2584 Mon Sep 17 00:00:00 2001 From: Oana Horvath Date: Wed, 20 Jan 2021 17:43:50 +0200 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/17309, https://github.com/mozilla-mobile/fenix/issues/13447, https://github.com/mozilla-mobile/fenix/issues/14534 UI tests: changed the way page Url is verified --- .../mozilla/fenix/ui/NavigationToolbarTest.kt | 4 ++-- .../org/mozilla/fenix/ui/SettingsBasicsTest.kt | 1 + .../org/mozilla/fenix/ui/robots/BrowserRobot.kt | 16 +++++++++------- 3 files changed, 12 insertions(+), 9 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 ae9c165e66..b298379839 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/NavigationToolbarTest.kt @@ -58,9 +58,9 @@ class NavigationToolbarTest { mDevice.waitForIdle() }.openNavigationToolbar { }.enterURLAndEnterToBrowser(nextWebPage.url) { - mDevice.waitForIdle() verifyUrl(nextWebPage.url.toString()) - mDevice.pressBack() + }.openThreeDotMenu { + }.goBack { mDevice.waitForIdle() verifyUrl(defaultWebPage.url.toString()) } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt index 5345f38cb1..14d03757ad 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt @@ -120,6 +120,7 @@ class SettingsBasicsTest { navigationToolbar { }.enterURLAndEnterToBrowser(page2.url) { + verifyUrl(page2.url.toString()) }.openThreeDotMenu { clickAddBookmarkButton() } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index 26c9c7e2dd..13372a3d94 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -57,14 +57,14 @@ class BrowserRobot { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) sessionLoadedIdlingResource = SessionLoadedIdlingResource() - mDevice.waitNotNull( - Until.findObject(By.res("$packageName:id/mozac_browser_toolbar_url_view")), - waitingTime - ) - runWithIdleRes(sessionLoadedIdlingResource) { - onView(withId(R.id.mozac_browser_toolbar_url_view)) - .check(matches(withText(containsString(url.replace("http://", ""))))) + assertTrue( + mDevice.findObject( + UiSelector() + .resourceId("$packageName:id/mozac_browser_toolbar_url_view") + .textContains(url.replace("http://", "")) + ).waitForExists(waitingTime) + ) } } @@ -297,6 +297,8 @@ class BrowserRobot { fun createBookmark(url: Uri) { navigationToolbar { }.enterURLAndEnterToBrowser(url) { + // needs to wait for the right url to load before saving a bookmark + verifyUrl(url.toString()) }.openThreeDotMenu { clickAddBookmarkButton() }