> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobster.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Failed to get matching snapshot: Error getting main window kAXErrorServerNotFound

> XCTest found no accessibility server for the app. The app isn't in front, the phone is locked, or a system overlay took its place.

An XCUITest step fails with this line. Some Xcode versions write `Failed to get matching snapshots:`. Through WebDriverAgent and Appium, the same failure arrives as a `stale element reference` on a page-source or window-size request:

```text theme={"theme":"css-variables"}
The previously found element "Application 'com.example.app'" is not present in the current view anymore. Make sure the application UI has the expected state. Original error: Error getting main window kAXErrorServerNotFound
```

Mobster reads screens through WebDriverAgent, so a read on your iPhone can hit this. On iOS 26.0.1 (23 Sep 2026), with Safari in front, WebDriverAgent took an invisible system overlay, `com.apple.siri.IntelligentLight`, for the app in front, and every screen read failed after about 8 seconds. Mobster sets the app it opened as WebDriverAgent's active app and retries the read once. In this case, the retry took 0.58 s.

## Why it happens

XCTest reads a screen by asking the app's accessibility server for a snapshot, starting from the app's main window. `kAXErrorServerNotFound` means no server answered for that app. Reported causes include:

| What you see on the phone | The cause |
| - | - |
| The lock screen | The phone is locked. Accessibility reads don't work on a locked iPhone |
| The Home Screen, another app, or nothing | The app crashed, quit, or opened in the background. XCTest is asking an app that isn't in front |
| The app, under Siri, Control Center or a banner | WebDriverAgent picks the app in front by checking what sits at one point of the screen, `activeAppDetectionPoint`. Its default is `MIN(w, h) * 0.2, MIN(w, h) * 0.2`, near the top left, where banners and overlays sit |
| The app, and every other app fails too | In one report (Dec 2023), an Appium contributor found `testmanagerd` unable to write `com.apple.Accessibility` settings, and only a restart of the phone cleared it |
| The app, and only your app fails | Something in the app breaks its accessibility. In one report (Jan 2024), a React Native library that called `class_getClassMethod` caused it, and `class_copyMethodList` fixed it |

## Fix

1. Unlock the iPhone and look at it. Close Siri, Control Center and any banner. If the app isn't on screen, open it again.

2. Bring the app to the front before you read it. In an XCUITest, call `app.activate()`, or `app.launch()`, before the query. Through Appium, run `mobile: activateApp` with `{"bundleId": "com.example.app"}`. Through WebDriverAgent itself:

   ```sh theme={"theme":"css-variables"}
   curl -s -X POST http://127.0.0.1:8100/session/<session id>/wda/apps/activate \
     -H 'Content-Type: application/json' -d '{"bundleId": "com.example.app"}'
   ```

3. Point WebDriverAgent at the app. Set `defaultActiveApplication` to its bundle ID, and `activeAppDetectionPoint` to a point inside the app's content, as `"x,y"` in points. Mobster tries `160,320` first:

   ```sh theme={"theme":"css-variables"}
   curl -s -X POST http://127.0.0.1:8100/session/<session id>/appium/settings \
     -H 'Content-Type: application/json' \
     -d '{"settings": {"defaultActiveApplication": "com.example.app", "activeAppDetectionPoint": "160,320"}}'
   ```

   Through Appium, pass the same two settings to `updateSettings`. Mobster sets the detection point on every session, and names each app it opens as the active one.

4. Close the app in the app switcher and open it again. A restart of WebDriverAgent doesn't clear a stuck accessibility server, and closing its app does.

5. If every app fails, Settings included, restart the iPhone.

## Check it worked

`curl -s http://127.0.0.1:8100/source` returns JSON whose `value` is the screen's XML, starting with the app's `XCUIElementTypeApplication`. An XCUITest query on the same screen passes.

Checked 5 Nov 2026 against Mobster 0.4.0. The commands were checked with Xcode 26.4. Back to [Troubleshooting](https://docs.mobster.dev/troubleshooting.md#tasks).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.