From 8fa7e645f08f1b2f2b146a239681e9a386bd13c7 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Tue, 27 Jun 2023 13:04:30 +0300 Subject: [PATCH] Bug 1840581 - Add condition before switching to private browsing --- .../mozilla/fenix/ui/robots/HomeScreenRobot.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index 3c05d8e42f..c1f199e1e5 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -625,11 +625,18 @@ class HomeScreenRobot { } fun togglePrivateBrowsingMode() { - mDevice.findObject(UiSelector().resourceId("$packageName:id/privateBrowsingButton")) - .waitForExists( - waitingTime, - ) - privateBrowsingButton.click() + if ( + !itemWithResIdAndDescription( + "$packageName:id/privateBrowsingButton", + "Disable private browsing", + ).exists() + ) { + mDevice.findObject(UiSelector().resourceId("$packageName:id/privateBrowsingButton")) + .waitForExists( + waitingTime, + ) + privateBrowsingButton.click() + } } fun triggerPrivateBrowsingShortcutPrompt(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition {