Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open universal links (deep links) with XCUITest

Tags:

xcuitest

I would like to create several tests for native iOS application. To be more precise, I want to test deep links. But I am not sure how to trigger deep link with XCUITest and I don't really see how launch() and launcArguments (https://developer.apple.com/documentation/xctest/xcuiapplication) can help me. Did anybody have a chance to open deep link with XCUITest?

like image 726
olyv Avatar asked Oct 17 '22 13:10

olyv


2 Answers

In iOS 14 using Spotlight seems to work well:

    private func open(_ urlString: String) {
        XCUIDevice.shared.press(.home)
        XCUIApplication(bundleIdentifier: "com.apple.springboard").swipeDown()
        let spotlight = XCUIApplication(bundleIdentifier: "com.apple.Spotlight")
        spotlight.textFields["SpotlightSearchField"].typeText(urlString)
        spotlight.buttons["Go"].tap()
    }
like image 166
Luke Street Avatar answered Oct 21 '22 07:10

Luke Street


  1. Set safari as app like this

    let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")

  2. Open your email in safari

  3. Tap on the link
  4. Normally assert some element on app
like image 25
Jinesh Avatar answered Oct 21 '22 06:10

Jinesh