From ee5bf935de270a4a398374edacb7dce7a18f18f3 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Tue, 17 Oct 2023 15:32:17 +0100 Subject: [PATCH] Fix things --- .../Tests/DeeplinkTests.swift | 1 - TestTools/UITests/Safari.swift | 30 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/SwiftUIDemoAppUITests/Tests/DeeplinkTests.swift b/SwiftUIDemoAppUITests/Tests/DeeplinkTests.swift index 6fd432bc0..7dec237fe 100644 --- a/SwiftUIDemoAppUITests/Tests/DeeplinkTests.swift +++ b/SwiftUIDemoAppUITests/Tests/DeeplinkTests.swift @@ -45,7 +45,6 @@ final class DeeplinkTests: StreamTestCase { WHEN("user navigates to the app through deeplink") { Safari() .open(MockDeeplink.production) - .alertHandler() .tapOnOpenButton() } THEN("user joins the the specified call") { diff --git a/TestTools/UITests/Safari.swift b/TestTools/UITests/Safari.swift index 20917d5ba..b5f77550b 100644 --- a/TestTools/UITests/Safari.swift +++ b/TestTools/UITests/Safari.swift @@ -26,14 +26,18 @@ struct Safari { func open(_ url: URL) -> Self { safari.launch() _ = safari.wait(for: .runningForeground, timeout: 5) - - // Type the deeplink and execute it - let firstLaunchContinueButton = safari.buttons["Continue"] - if firstLaunchContinueButton.exists { - firstLaunchContinueButton.tap() - } + if #available(iOS 16.4, *) { + safari.open(url) + return self + } else { + // Type the deeplink and execute it + let firstLaunchContinueButton = safari.buttons["Continue"] + if firstLaunchContinueButton.exists { + firstLaunchContinueButton.tap() + } - return go(to: url) + return go(to: url) + } } @discardableResult @@ -49,14 +53,18 @@ struct Safari { } @discardableResult - func tapOnOpenButton(_ timeout: TimeInterval = 5) -> Self { + func tapOnOpenButton() -> Self { let openButton = safari.buttons.matching(NSPredicate(format: "label LIKE 'OPEN' OR label LIKE 'Open'")).firstMatch - + let reloadButton = safari.buttons["ReloadButton"] var counter = 0 - while !openButton.wait(timeout: timeout).exists || counter < 5 { - safari.buttons["ReloadButton"].tap() + + while !openButton.exists && counter < 5 { + reloadButton.wait().tap() + reloadButton.wait() + alertHandler() counter += 1 } + XCTAssertTrue(openButton.exists, "Open button does not exist") openButton.tap() return self