iOS deeplink redirection in Safari interfering with native alert


I have an issue with handling deeplink redirection in Appium.


I’ve automated a test for an iOS app that requires passing a deeplink in Safari and redirecting back to the app. The issue I’m having is that the deeplink is meant to logout of the app and it has to interact with a native alert. During the deeplink redirection this alert is ‘lost’ i.e. it’s not showing up when the app is reopened. It seems like a race condition, however I’m stuck trying to solve it.
I have tried to use wait() but the behaviour is still very inconsistent.

Q: Is there a way to open Safari in app?

Any other solutions or ideas?

Code snippet:

  //Deep Links//
  async openDeepLinkIOS(url: string) {
    await driver.execute('mobile: launchApp', {
      bundleId: '',

    const capabilities = driver.capabilities['deviceName']
    const urlField = await (capabilities.includes('iPad')
      ? $('~UnifiedTabBar')
      : $('-ios predicate string: label == "Address"'))

    await driver.sendKeys([url])
    await this.pressKeyIOS('go')
    //await this.wait(1000)

try also another way

// Java
            // from 14.3 xCode
            driver.get("your_app://" + linkTxt);

Hi @Aleksei thanks so much for the suggestion, it worked!!

driver.navigateTo(deeplinkUrl) //javascript + wdio

In the recent xcuitest driver version I’ve also added a new appium:initialDeeplinkUrl capability, which allows to start a test from a deep link. Available since iOS 16.4

1 Like

Awesome @mykola-mokhnach. Very cool!