Reputation: 953
I have a pretty complicated app with a lot of views and popovers for fast picking entries.
I'm not able to dismiss a popover. I tried a lot like:
When I record the it in XCode I get: app.otherElements["PopoverDismissRegion"]
Which makes no sense to me.
Hope someone can help.
Thx
Infos: iOS 10.2,Xcode 8.2.1, iPad Air 2 (Device and Simulator, same results)
Upvotes: 3
Views: 1691
Reputation: 3274
How do I have achieved this? This way below:
Find a starting coordinates origin x and origin y of the poped up view, ref: How to tap on a specific point using Xcode UITests
Then do the minus on coordinates to tap outside the frame of poped up view, Then do the tap action.
It will dismiss the Pop up , and tests will pass.
Upvotes: 0
Reputation: 743
Everything was working for me on iPhone simulators by just doing:
app.swipeDown(velocity: .fast)
I started to have problems when I wanted the same test to run on iPad simulators. The gesture was being applied but it was not big enough to dismiss the view. I tried different things like:
XCUIApplication().windows.element(boundBy: 0).tap()
or
app.otherElements["PopoverDismissRegion"].tap()
but none of the work. The view was still not being dismissed.
Doing more testing on it I found that the view will actually be dismissed sending the swipeDown
gesture if iPad Simulator is on landscape. So... I was able to solve the problem like this:
// If iPad, put the simulator on landscape mode
if UIDevice.current.userInterfaceIdiom == .pad {
XCUIDevice.shared.orientation = .landscapeLeft
}
// Perform the swipe
app.swipeDown(velocity: .fast)
// Restore device portrait mode
if UIDevice.current.userInterfaceIdiom == .pad {
XCUIDevice.shared.orientation = .portrait
}
Upvotes: 1