XCTest: Tap "Done" button in SFSafariViewController

981 views Asked by At

I'm opening a SFSafariViewController and can't find the "Done" Button to leave Safari again.

Also if I try to solve it with a swipeRight XCode creates code that it can't use in a test afterwards

let element = app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 2)
    element.swipeRight()

Any idea how to dismiss SFSafariViewController? (I don't need access to elements in the browser).

enter image description here

1

There are 1 answers

0
Amaury Vela On

This worked for me:

let doneButton = app.buttons["Done"]
waitUntilElementExists(element: doneButton)
doneButton.tap()

The waitUntilElementExists I think its the key to making it work, I wait 60 seconds tops.