I use this:
func open(appPath pathString: String) {
openFromSafari("com.myapp.myapp://my.domain.com\(pathString)")
XCTAssert(app.wait(for: .runningForeground, timeout: 5))
}
private func openFromSafari(_ urlString: String) {
let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")
safari.launch()
// Make sure Safari is really running before asserting
XCTAssert(safari.wait(for: .runningForeground, timeout: 5))
// Type the deeplink and execute it
let firstLaunchContinueButton = safari.buttons["Continue"]
if firstLaunchContinueButton.exists {
firstLaunchContinueButton.tap()
}
safari.textFields["Address"].tap()
let keyboardTutorialButton = safari.buttons["Continue"]
if keyboardTutorialButton.exists {
keyboardTutorialButton.tap()
}
safari.typeText(urlString)
safari.buttons["go"].tap()
let openButton = safari.buttons["Open"]
let _ = openButton.waitForExistence(timeout: 2)
if openButton.exists {
openButton.tap()
}
}