In iOS 15 I’ve got a date picker in my app that uses the .compact
style so it presents the date and time selection UI as popovers.
I can’t find a way to dismiss the popover in a UI test, having tried suggestions for popover dismissal such as:
app.otherElements["PopoverDismissRegion"]
(didn’t exist)app.otherElements["dismiss popup"].tap()
(didn’t exist).windows.element(boundBy: 0).tap()
(just hits the centre of the screen, which is still the popover so does nothing of use)
2
Answers
It took a bit of time searching around, looking for non-datepicker related answers that might work but I found this answer, which suggested that this would work:
app.swipeDown(velocity: .fast)
That did the trick for me on an iPhone simulator and according to the answer it works for landscape iPads too, though not on portrait.
Duplicating the answer as the original doesn't reference date picker so is harder to find!
It’s incredible that tapping the "supplied" dismissal button doesn’t work, eh?
I’ve solved this by "force" tapping another element I know to be on the screen (a header text). This obviously won’t work if the date picker is covering that element, but in my case it never has.