Safari Test Setup Issues: "No Webview Has Been Detected" on iOS 16.0, 17.x, 18.0

I’m encountering an issue with Appium when trying to run Safari tests on multiple devices and iOS versions (16.0, 17.x, 18.0). The tests often fail with the error message “No Webview has been detected…”

Activating a recent webview
Retrieving contexts and views
No web frames found.
Could not find any webviews yet, retrying
Encountered internal error running command: Error: No webview has been detected after 31511ms. You may try to change the 'webviewConnectTimeout' capability value to modify the timeout.
    at XCUITestDriver.activateRecentWebview (/xcuitest/xcuitest-7.15.3/lib/commands/context.js:95:15)
    at XCUITestDriver.start (/xcuitest/xcuitest-7.15.3/lib/driver.js:646:7)
    AppiumDriver.createSession (/appium/appium-2.6.0/lib/appium.js:717:35)

This error seems to originate from the activateRecentWebview function in the Appium XCUITestDriver:

No webview has been detected after ${elapsedMs.toFixed(0)}ms.
You may try to change the 'webviewConnectTimeout' capability value to modify the timeout.

Setup Details:

  • Appium Version: 2.6.0
  • XCUITestDriver Version: 7.15.3
  • Devices: Multiple iOS versions (16.0, 17.x, 18.0)

Related Capabilities:

{
  "appium:safariInitialUrl": "about:blank",
  "autoWebview": true,
  "webviewConnectTimeout": "30000"
}

This issue seems to be more prevalent on Intel Macs compared to ARM-based Macs. I have tried increasing the webviewConnectTimeout, but I’d prefer not to rely on this approach.
Current Considerations:
I’m considering experimenting with the following capabilities to see if they resolve the issue:

{
  "includeSafariInWebviews": true,
  "ignoreAboutBlankUrl": false,
  "webviewConnectRetries": <value>
}

Question:
Has anyone else experienced similar issues with Safari tests on these iOS versions? Are there any additional capabilities or configurations that might help resolve this problem? This is an intermittent issue on my end, and I’d like to understand its root cause.

  • Always use the most recent driver and server versions. there might be bug fixes applied there for this or related issues
  • There is known issue in Safari on iOS 17.4 and 17.5, where the remote debugger does not return any pages. Upgrading to a newer version or downgrading it helps to workaround it
  • Check how long it takes for native Safari debugger to detect opened pages in the same environment and adjust the number of retries appropriately
  • Setting “appium:safariInitialUrl” to “about:blank” won’t work. The remote debugger only supports http and https schemes

Thank you for your response. Could you please let me know the possible reasons behind this issue? Could it be due to hardware limitations or high CPU load that the web inspector is unable to detect any webpages, even when I explicitly pass the capability includeSafariInWebviews to Appium?

No idea. The web inspector service code is not open sourced, so it could be anything.

Is there any way to “refresh” the web inspector using any patch on appium-xcuit-driver?