From ba3f51814c71ef154bbd54e477120307886489db Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Tue, 26 Oct 2021 09:53:20 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/18421 fix and re-enable verifyContextShareLink, verifyContextSaveImage and verifyContextMixedVariations UI tests --- .../org/mozilla/fenix/ui/ContextMenusTest.kt | 5 ++-- .../mozilla/fenix/ui/robots/BrowserRobot.kt | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt index 046055cfb0..0549c23658 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt @@ -32,7 +32,6 @@ import org.mozilla.fenix.ui.robots.navigationToolbar * */ -@Ignore("Test failures: https://github.com/mozilla-mobile/fenix/issues/18421") class ContextMenusTest { private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) private lateinit var mockWebServer: MockWebServer @@ -53,6 +52,7 @@ class ContextMenusTest { mockWebServer.shutdown() } + @Ignore("Test failures: https://github.com/mozilla-mobile/fenix/issues/18421") @Test fun verifyContextOpenLinkNewTab() { val pageLinks = @@ -76,6 +76,7 @@ class ContextMenusTest { } } + @Ignore("Test failures: https://github.com/mozilla-mobile/fenix/issues/18421") @Test fun verifyContextOpenLinkPrivateTab() { val pageLinks = @@ -177,7 +178,6 @@ class ContextMenusTest { } @Test - @Ignore("Intermittent: https://github.com/mozilla-mobile/fenix/issues/12309") fun verifyContextSaveImage() { val pageLinks = TestAssetHelper.getGenericAsset(mockWebServer, 4) @@ -202,7 +202,6 @@ class ContextMenusTest { } @Test - @Ignore("Intermittent: https://github.com/mozilla-mobile/fenix/issues/12309") fun verifyContextMixedVariations() { val pageLinks = TestAssetHelper.getGenericAsset(mockWebServer, 4) 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 07b7c40772..909f2cba3b 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 @@ -317,11 +317,31 @@ class BrowserRobot { } fun longClickMatchingText(expectedText: String) { - val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - mDevice.waitNotNull(Until.findObject(text(expectedText)), waitingTime) + try { + mDevice.waitForWindowUpdate(packageName, waitingTime) + mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView")) + .waitForExists(waitingTime) + mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime) + val link = mDevice.findObject(By.textContains(expectedText)) + link.click(LONG_CLICK_DURATION) + } catch (e: NullPointerException) { + println(e) - val element = mDevice.findObject(text(expectedText)) - element.click(LONG_CLICK_DURATION) + // Refresh the page in case the first long click didn't succeed + navigationToolbar { + }.openThreeDotMenu { + }.refreshPage { + mDevice.waitForIdle() + } + + // Long click again the desired text + mDevice.waitForWindowUpdate(packageName, waitingTime) + mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView")) + .waitForExists(waitingTime) + mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime) + val link = mDevice.findObject(By.textContains(expectedText)) + link.click(LONG_CLICK_DURATION) + } } fun longClickAndCopyText(expectedText: String, selectAll: Boolean = false) {