Skip to content

Commit 5634917

Browse files
AndiAJajoltan@mozilla.com
authored andcommitted
Bug 1999589 - Fix verifyClockFormInteractionsTest UI test r=mcarare
The UI test was failing on Firebase because the time was sometimes set by default to PM, meaning that when we set the time to 10:10 it would actually set it to 22:10 and we were checking for 10:10 To fix this problem, I've added an extra step, namely to always set the time to AM. Another problem noticed while checking locally, is that the time couldn't actually be selected properly due to some selector changes. (not sure why this hasn't occurred when Gabi did the first changes) To fix this I've updated the selectors used to select the time. The UI test [[ https://treeherder.mozilla.org/jobs?repo=try&selectedTaskRun=DL5hCDyxTeGVmr-6TCirWg.0&revision=2201050a90d520d1ccc37a50c8928926727435f6 | successfully passed ]] 25x on Firebase ✅ Differential Revision: https://phabricator.services.mozilla.com/D272217
1 parent c0ed632 commit 5634917

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/helpers/MatcherHelper.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ object MatcherHelper {
5454
return mDevice.findObject(UiSelector().resourceId(resourceId).index(index))
5555
}
5656

57+
fun itemWithClassNameAndContainingDescription(className: String, description: String): UiObject {
58+
Log.i(TAG, "Looking for item with class name: $className and description: $description")
59+
return mDevice.findObject(UiSelector().className(className).descriptionContains(description))
60+
}
61+
5762
fun itemWithClassNameAndIndex(className: String, index: Int): UiObject {
5863
Log.i(TAG, "Looking for item with class name: $className and index: $index")
5964
return mDevice.findObject(UiSelector().className(className).index(index))

mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import org.mozilla.fenix.helpers.MatcherHelper.assertItemTextEquals
6565
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
6666
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectIsGone
6767
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
68+
import org.mozilla.fenix.helpers.MatcherHelper.itemWithClassNameAndContainingDescription
6869
import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription
6970
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
7071
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
@@ -766,11 +767,21 @@ class BrowserRobot {
766767
}
767768

768769
fun selectTime(hour: Int, minute: Int) {
769-
Log.i(TAG, "selectTime: Trying to select time picker hour: $hour and minute: $minute")
770-
itemWithDescription("$hour o'clock").click()
770+
Log.i(TAG, "selectTime: Trying to select time picker hour: $hour and minute: $minute AM")
771+
itemWithClassNameAndContainingDescription(
772+
"android.widget.TextView",
773+
"$hour o'clock",
774+
).click()
771775
waitForAppWindowToBeUpdated()
772-
itemWithDescription("$minute minutes").click()
773-
Log.i(TAG, "selectTime: Selected time picker hour: $hour and minute: $minute")
776+
itemWithClassNameAndContainingDescription(
777+
"android.widget.TextView",
778+
"$minute minutes",
779+
).click()
780+
itemWithResIdContainingText(
781+
"$packageName:id/material_clock_period_am_button",
782+
"AM",
783+
).click()
784+
Log.i(TAG, "selectTime: Selected time picker hour: $hour and minute: $minute AM")
774785
}
775786

776787
fun verifySelectedDate() {

0 commit comments

Comments
 (0)