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 {