I am working on UI Test for several System Alerts in a row (ie. a video app to get permission for Camera, Microphone and Photos). With a sample project, it seems the new method addUIInterruptionMonitorWithDescription
is not working for Landscape mode.
I come across this post Swift UI Test - User Notifications System Alert, but the case is different for me.
My code looks like this:
let desc = "\u{201c}Alert\u{201d} Would Like to Access the Camera"
let app = XCUIApplication()
addUIInterruptionMonitorWithDescription(desc) { (alert) -> Bool in
let okButton = alert.buttons["OK"]
print(okButton.frame)
okButton.tap()
return true
}
app.buttons["Alert"].tap()
It works for Portrait, not Landscape. The case can be reproduced by Simulator and Device.
Moreover the okButton.frame
I got in Portrait is
CGRect
▿ origin : CGPoint
- x : 207.0
- y : 387.666666666667
▿ size : CGSize
- width : 135.0
- height : 44.0
but the frame in Landscape shows like this
CGRect
▿ origin : CGPoint
- x : 143.333333333333
- y : 368.0
▿ size : CGSize
- width : 44.0
- height : 135.0
The test failure error I got is this one
test failure: -[AlertUITests testExample()] failed: UI Testing Failure - Failed to scroll to visible (by AX action) Button 0x14df73840: traits: 8589934593, {{277.0, 345.0}, {46.0, 30.0}}, label: 'Button', error: Error -25204 performing AXAction 2003
Any idea?
EDIT 1
Submitted to Radar rdar://23931990