From 890833d7acb5f1755da07cbccf2c1c7f6807af8f Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Mon, 5 Aug 2019 08:09:34 -0700 Subject: [PATCH] No issue: Fix failing UI tests because of renamed views (#4527) --- .../mozilla/fenix/ui/robots/SearchRobot.kt | 10 ++++---- .../ui/screenshots/MenuScreenShotTest.kt | 23 ++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt index 70076135a..8ee6ce800 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt @@ -17,18 +17,18 @@ import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import androidx.test.uiautomator.UiDevice import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By +import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiObject import androidx.test.uiautomator.UiScrollable +import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.Until import org.hamcrest.CoreMatchers.allOf +import org.hamcrest.CoreMatchers.startsWith import org.hamcrest.Matchers import org.mozilla.fenix.R import org.mozilla.fenix.helpers.TestAssetHelper -import androidx.test.uiautomator.UiSelector -import org.hamcrest.CoreMatchers.startsWith /** * Implementation of Robot Pattern for the search fragment. @@ -108,12 +108,12 @@ private fun allowPermissionButton(): UiObject { private fun scanButton(): ViewInteraction { mDevice.wait(Until.findObject(By.res("R.id.search_scan_button")), TestAssetHelper.waitingTime) - return onView(allOf(withId(R.id.search_scan_button))) + return onView(allOf(withId(R.id.searchScanButton))) } private fun shortcutsButton(): ViewInteraction { mDevice.wait(Until.findObjects(By.res("R.id.search_shortcuts_button")), TestAssetHelper.waitingTime) - return onView(withId(R.id.search_shortcuts_button)) + return onView(withId(R.id.searchShortcutsButton)) } private fun assertDuckDuckGoURL() { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/screenshots/MenuScreenShotTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/screenshots/MenuScreenShotTest.kt index 28356ef34..e09e76990 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/screenshots/MenuScreenShotTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/screenshots/MenuScreenShotTest.kt @@ -14,28 +14,25 @@ import androidx.test.rule.ActivityTestRule import androidx.test.uiautomator.By import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.Until - -import org.junit.After -import org.junit.Rule -import org.junit.Test -import org.mozilla.fenix.HomeActivity -import org.mozilla.fenix.R -import org.mozilla.fenix.helpers.HomeActivityTestRule -import org.mozilla.fenix.helpers.TestAssetHelper - -import tools.fastlane.screengrab.Screengrab -import tools.fastlane.screengrab.locale.LocaleTestRule - import br.com.concretesolutions.kappuccino.actions.ClickActions import br.com.concretesolutions.kappuccino.extensions.type import okhttp3.mockwebserver.MockWebServer import org.hamcrest.Matchers +import org.junit.After import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mozilla.fenix.HomeActivity +import org.mozilla.fenix.R import org.mozilla.fenix.helpers.AndroidAssetDispatcher +import org.mozilla.fenix.helpers.HomeActivityTestRule +import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.click import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.swipeToBottom +import tools.fastlane.screengrab.Screengrab +import tools.fastlane.screengrab.locale.LocaleTestRule class MenuScreenShotTest : ScreenshotTest() { @@ -234,7 +231,7 @@ fun saveToCollectionButton() = Espresso.onView(Matchers.allOf(ViewMatchers.withI fun collectionsButton() = Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.collection_overflow_button))).click() fun addBookmarkFolderButton() = Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.add_bookmark_folder))).click() fun confirmAddFolderButton() = Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.confirm_add_folder_button))).click() -fun addFolderName() = Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.bookmark_add_folder_title_edit))) +fun addFolderName() = Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.bookmarkAddFolderTitleEdit))) .type("folder") fun bookmarkFolderMenu() = Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.overflow_menu))).click() fun editBookmarkFolder() = ClickActions.click { text(R.string.bookmark_menu_edit_button) }