From 703e6fa078b288b2874e829ec8a6e5be0d04e56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 27 Oct 2026 19:14:12 +0100 Subject: [PATCH 1/8] fix(ios): find and answer a SpringBoard alert on a foldable's other panel A foldable's SpringBoard has windows on each panel, but springboard.frame names only the outer one. The blocking-modal probe dropped an alert whose center lay outside that frame, so an "Open in" launch confirmation on the unfolded iPhone Duo's inner panel read as absent, and alert get/accept answered ALERT_NOT_FOUND for every session app other than SpringBoard. The activation tap also routed through SpringBoard's first window, the dark outer panel, so even a found alert was never answered. The probe now finds each alert or sheet through the SpringBoard window that hosts it, places it against that window, and routes the alert activation through the same window's display. Co-Authored-By: Claude Opus 5.5 --- .../RunnerTests+Alert.swift | 14 +++++- ...rTests+BlockingSystemModalResolution.swift | 9 ++-- .../RunnerTests+SynthesizedInteraction.swift | 19 ++++++++ .../RunnerTests+SystemModal.swift | 48 ++++++++++++------- 4 files changed, 67 insertions(+), 23 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift index 3cb00114d1..0f9fe4b7f5 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift @@ -12,6 +12,9 @@ extension RunnerTests { let ownerApp: XCUIApplication let buttons: [XCUIElement] let source: RunnerAlertSource + /// The window a SpringBoard modal is hosted in. Its activation routes through this window, + /// because `ownerApp`'s first window can be on another panel of a foldable. + var window: XCUIElement? = nil } static let defaultAlertCommandTimeout: TimeInterval = 10 @@ -162,7 +165,13 @@ extension RunnerTests { ) return } - switch synthesizedTapAt(app: alert.ownerApp, x: frame.midX, y: frame.midY, deadline: deadline) { + switch synthesizedTapAt( + app: alert.ownerApp, + x: frame.midX, + y: frame.midY, + context: alert.window.flatMap { synthesizedCoordinateContext(window: $0) }, + deadline: deadline + ) { case .performed?: typealias WaitForQuiescence = @convention(c) (NSObject, Selector, Bool) -> Void let waitForQuiescence = unsafeBitCast( @@ -217,7 +226,8 @@ extension RunnerTests { root: modal.root, ownerApp: modal.ownerApp, buttons: buttons, - source: .blockingSystemModal + source: .blockingSystemModal, + window: modal.window ) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift index 687d36d8b8..6fe202f848 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift @@ -5,6 +5,8 @@ extension RunnerTests { let root: XCUIElement let ownerApp: XCUIApplication let actions: [XCUIElement] + /// The SpringBoard window hosting `root`, or nil for a remote host queried as a whole app. + var window: XCUIElement? = nil } enum BlockingSystemModalResolution { @@ -27,15 +29,16 @@ extension RunnerTests { return .absent } - let springboardActions = actionableElements(in: springboardModal) + let springboardActions = actionableElements(in: springboardModal.root) if !RemoteHostedSystemModalPolicy.shouldProbeRemoteHost( springboardActionCount: springboardActions.count ) { return .resolved( ResolvedBlockingSystemModal( - root: springboardModal, + root: springboardModal.root, ownerApp: springboard, - actions: springboardActions + actions: springboardActions, + window: springboardModal.window ) ) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift index 703c9c22eb..988a19f267 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift @@ -441,6 +441,25 @@ extension RunnerTests { ) } +#if os(iOS) + /// The context for a point measured on a window the caller already holds, such as the + /// SpringBoard window hosting a system alert. Nil when that window has no usable frame. + @MainActor + func synthesizedCoordinateContext(window: XCUIElement) -> SynthesizedCoordinateContext? { + let frame = safely("MODAL_WINDOW", CGRect.null) { window.frame } + guard !frame.isNull, frame.width.isFinite, frame.height.isFinite, + frame.width > 0, frame.height > 0 + else { + return nil + } + return SynthesizedCoordinateContext( + referenceFrame: frame, + resolvedWindow: window, + accessibilityHealth: mainOwned.accessibilityHealth + ) + } +#endif + @MainActor func synthesizedCoordinateContext( app: XCUIApplication, diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift index 726759e8d0..28cc444dde 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift @@ -102,17 +102,20 @@ extension RunnerTests { ) } + /// A SpringBoard modal and the window that hosts it. A foldable's SpringBoard has windows on + /// each panel, and `springboard.frame` names only one of them, so the modal is placed against + /// its own window and its activation is routed through that window's display. + struct SpringBoardModal { + let root: XCUIElement + let window: XCUIElement + } + func firstBlockingSystemModal( in springboard: XCUIApplication, deadline: Date = .distantFuture - ) -> XCUIElement? { - let alerts = safeElementsQuery { - springboard.alerts.allElementsBoundByIndex - } - for alert in alerts { - if safeIsBlockingSystemModal(alert, in: springboard) { - return alert - } + ) -> SpringBoardModal? { + if let alert = firstBlockingSystemModal(in: springboard, matching: .alert) { + return alert } // Don't start the second (sheet) enumeration once the shared probe deadline is spent (#1244). @@ -121,15 +124,24 @@ extension RunnerTests { return nil } - let sheets = safeElementsQuery { - springboard.sheets.allElementsBoundByIndex + return firstBlockingSystemModal(in: springboard, matching: .sheet) + } + + private func firstBlockingSystemModal( + in springboard: XCUIApplication, + matching type: XCUIElement.ElementType + ) -> SpringBoardModal? { + let windows = safeElementsQuery { + springboard.windows.containing(type, identifier: nil).allElementsBoundByIndex } - for sheet in sheets { - if safeIsBlockingSystemModal(sheet, in: springboard) { - return sheet + for window in windows { + let modals = safeElementsQuery { + window.descendants(matching: type).allElementsBoundByIndex + } + for modal in modals where safeIsBlockingSystemModal(modal, in: window) { + return SpringBoardModal(root: modal, window: window) } } - return nil } @@ -137,16 +149,16 @@ extension RunnerTests { safely("MODAL_QUERY", [], fetch) } - private func safeIsBlockingSystemModal(_ element: XCUIElement, in springboard: XCUIApplication) -> Bool { - safely("MODAL_CHECK", false) { isBlockingSystemModal(element, in: springboard) } + private func safeIsBlockingSystemModal(_ element: XCUIElement, in window: XCUIElement) -> Bool { + safely("MODAL_CHECK", false) { isBlockingSystemModal(element, in: window) } } - private func isBlockingSystemModal(_ element: XCUIElement, in springboard: XCUIApplication) -> Bool { + private func isBlockingSystemModal(_ element: XCUIElement, in window: XCUIElement) -> Bool { guard element.exists else { return false } let frame = element.frame if frame.isNull || frame.isEmpty { return false } - let viewport = springboard.frame + let viewport = window.frame if viewport.isNull || viewport.isEmpty { return false } let center = CGPoint(x: frame.midX, y: frame.midY) From 25ce4a6df323d1ca45475351dcc83daf0ce33fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 27 Oct 2026 19:23:23 +0100 Subject: [PATCH 2/8] fix(ios): verify an alert answer against the window that hosts it The post-tap observation placed SpringBoard alerts against the application frame, which on a foldable names one panel, so an alert on the other panel read as gone right after any tap. Each window now bounds what it hosts. The probe also stops between windows once its deadline is spent. Co-Authored-By: Claude Opus 5.5 --- .../AgentDeviceRunnerUITests/RunnerTests+Alert.swift | 2 -- .../RunnerTests+AlertObservation.swift | 5 ++++- .../RunnerTests+BlockingSystemModalResolution.swift | 1 - .../RunnerTests+SynthesizedInteraction.swift | 2 +- .../RunnerTests+SystemModal.swift | 8 +++++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift index 0f9fe4b7f5..f7f339620a 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift @@ -12,8 +12,6 @@ extension RunnerTests { let ownerApp: XCUIApplication let buttons: [XCUIElement] let source: RunnerAlertSource - /// The window a SpringBoard modal is hosted in. Its activation routes through this window, - /// because `ownerApp`'s first window can be on another panel of a foldable. var window: XCUIElement? = nil } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift index a010810149..6cd7839d59 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift @@ -64,7 +64,10 @@ extension RunnerTests { matches = snapshot.elementType == .window && containsDismissPopupMarker(snapshot) } if matches && visible { return [snapshot] } - return snapshot.children.flatMap { alertSnapshots(in: $0, source: source, viewport: viewport) } + // A window is the viewport of what it hosts: a foldable's SpringBoard has a window on each + // panel, and the application frame names only one of them. + let childViewport = snapshot.elementType == .window && !frame.isNull && !frame.isEmpty ? frame : viewport + return snapshot.children.flatMap { alertSnapshots(in: $0, source: source, viewport: childViewport) } } private func containsDismissPopupMarker(_ snapshot: XCUIElementSnapshot) -> Bool { diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift index 6fe202f848..b8af43648d 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift @@ -5,7 +5,6 @@ extension RunnerTests { let root: XCUIElement let ownerApp: XCUIApplication let actions: [XCUIElement] - /// The SpringBoard window hosting `root`, or nil for a remote host queried as a whole app. var window: XCUIElement? = nil } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift index 988a19f267..218358ac21 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift @@ -443,7 +443,7 @@ extension RunnerTests { #if os(iOS) /// The context for a point measured on a window the caller already holds, such as the - /// SpringBoard window hosting a system alert. Nil when that window has no usable frame. + /// SpringBoard window hosting a system alert. @MainActor func synthesizedCoordinateContext(window: XCUIElement) -> SynthesizedCoordinateContext? { let frame = safely("MODAL_WINDOW", CGRect.null) { window.frame } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift index 28cc444dde..0e25f8ec0d 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift @@ -114,7 +114,7 @@ extension RunnerTests { in springboard: XCUIApplication, deadline: Date = .distantFuture ) -> SpringBoardModal? { - if let alert = firstBlockingSystemModal(in: springboard, matching: .alert) { + if let alert = firstBlockingSystemModal(in: springboard, matching: .alert, deadline: deadline) { return alert } @@ -124,17 +124,19 @@ extension RunnerTests { return nil } - return firstBlockingSystemModal(in: springboard, matching: .sheet) + return firstBlockingSystemModal(in: springboard, matching: .sheet, deadline: deadline) } private func firstBlockingSystemModal( in springboard: XCUIApplication, - matching type: XCUIElement.ElementType + matching type: XCUIElement.ElementType, + deadline: Date ) -> SpringBoardModal? { let windows = safeElementsQuery { springboard.windows.containing(type, identifier: nil).allElementsBoundByIndex } for window in windows { + guard Date() < deadline else { return nil } let modals = safeElementsQuery { window.descendants(matching: type).allElementsBoundByIndex } From a3daa4ccb1a6ba0652435604385a26948082c899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 27 Oct 2026 19:34:35 +0100 Subject: [PATCH 3/8] refactor(ios): refuse an alert tap whose host window is unreadable An alert resolved through its SpringBoard host window no longer falls back to the owner app's first window when that window's frame cannot be read; on a foldable that fallback is another panel. The activation reports the refusal instead. The host window is an immutable field, the frame validation is shared through SynthesizedCoordinateContext(validating:), and the modal probe checks its deadline before each modal it reads. Co-Authored-By: Claude Opus 5.5 --- .../RunnerTests+Alert.swift | 23 +++++++++++++--- ...rTests+BlockingSystemModalResolution.swift | 5 ++-- ...RunnerTests+SynthesizedGesturePolicy.swift | 20 ++++++++++++++ .../RunnerTests+SynthesizedInteraction.swift | 26 +------------------ .../RunnerTests+SystemModal.swift | 7 +++-- .../RunnerTests+SystemModalTests.swift | 7 ++++- 6 files changed, 55 insertions(+), 33 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift index f7f339620a..c4c6742414 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift @@ -12,7 +12,8 @@ extension RunnerTests { let ownerApp: XCUIApplication let buttons: [XCUIElement] let source: RunnerAlertSource - var window: XCUIElement? = nil + /// The window hosting a SpringBoard modal; nil routes through `ownerApp`. + let window: XCUIElement? } static let defaultAlertCommandTimeout: TimeInterval = 10 @@ -163,11 +164,27 @@ extension RunnerTests { ) return } + var hostContext: SynthesizedCoordinateContext? + if let window = alert.window { + // Never fall back to the owner app's first window: on a foldable it can be another panel. + guard let context = SynthesizedCoordinateContext( + validating: safely("ALERT_WINDOW", CGRect.null) { window.frame }, + resolvedWindow: window, + accessibilityHealth: mainOwned.accessibilityHealth + ) else { + outcome = .unsupported( + message: "alert activation could not read the window hosting the alert", + hint: "Inspect the current alert before deciding whether to act again." + ) + return + } + hostContext = context + } switch synthesizedTapAt( app: alert.ownerApp, x: frame.midX, y: frame.midY, - context: alert.window.flatMap { synthesizedCoordinateContext(window: $0) }, + context: hostContext, deadline: deadline ) { case .performed?: @@ -238,7 +255,7 @@ extension RunnerTests { guard !buttons.isEmpty else { return nil } - return RunnerAlert(root: root, ownerApp: ownerApp, buttons: buttons, source: source) + return RunnerAlert(root: root, ownerApp: ownerApp, buttons: buttons, source: source, window: nil) } private func firstExistingElement(in elements: [XCUIElement]) -> XCUIElement? { diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift index b8af43648d..c3a8bdb701 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift @@ -5,7 +5,8 @@ extension RunnerTests { let root: XCUIElement let ownerApp: XCUIApplication let actions: [XCUIElement] - var window: XCUIElement? = nil + /// The SpringBoard window hosting `root`; nil for a remote host queried as a whole app. + let window: XCUIElement? } enum BlockingSystemModalResolution { @@ -66,7 +67,7 @@ extension RunnerTests { // inside actionableElements turn that disappearance into an empty result. let actions = actionableElements(in: host) guard !actions.isEmpty else { continue } - return ResolvedBlockingSystemModal(root: host, ownerApp: host, actions: actions) + return ResolvedBlockingSystemModal(root: host, ownerApp: host, actions: actions, window: nil) } return nil } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift index f78e61809c..bd45b0d90b 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift @@ -190,3 +190,23 @@ extension RunnerTests { + " fallbackAttempted=\(fallbackAttempted)" } } + +extension SynthesizedCoordinateContext { + /// Nil when `referenceFrame` is not a finite, non-empty box a point can be placed in. + init?( + validating referenceFrame: CGRect, + resolvedWindow: XCUIElement?, + accessibilityHealth: RunnerAccessibilityHealth + ) { + guard referenceFrame.width.isFinite, referenceFrame.height.isFinite, + referenceFrame.width > 0, referenceFrame.height > 0 + else { + return nil + } + self.init( + referenceFrame: referenceFrame, + resolvedWindow: resolvedWindow, + accessibilityHealth: accessibilityHealth + ) + } +} diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift index 218358ac21..b0598958e5 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift @@ -441,25 +441,6 @@ extension RunnerTests { ) } -#if os(iOS) - /// The context for a point measured on a window the caller already holds, such as the - /// SpringBoard window hosting a system alert. - @MainActor - func synthesizedCoordinateContext(window: XCUIElement) -> SynthesizedCoordinateContext? { - let frame = safely("MODAL_WINDOW", CGRect.null) { window.frame } - guard !frame.isNull, frame.width.isFinite, frame.height.isFinite, - frame.width > 0, frame.height > 0 - else { - return nil - } - return SynthesizedCoordinateContext( - referenceFrame: frame, - resolvedWindow: window, - accessibilityHealth: mainOwned.accessibilityHealth - ) - } -#endif - @MainActor func synthesizedCoordinateContext( app: XCUIApplication, @@ -484,13 +465,8 @@ extension RunnerTests { } else { return nil } - guard referenceFrame.width.isFinite, referenceFrame.height.isFinite, - referenceFrame.width > 0, referenceFrame.height > 0 - else { - return nil - } return SynthesizedCoordinateContext( - referenceFrame: referenceFrame, + validating: referenceFrame, resolvedWindow: window, accessibilityHealth: health ) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift index 0e25f8ec0d..59e2508c13 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift @@ -140,8 +140,11 @@ extension RunnerTests { let modals = safeElementsQuery { window.descendants(matching: type).allElementsBoundByIndex } - for modal in modals where safeIsBlockingSystemModal(modal, in: window) { - return SpringBoardModal(root: modal, window: window) + for modal in modals { + guard Date() < deadline else { return nil } + if safeIsBlockingSystemModal(modal, in: window) { + return SpringBoardModal(root: modal, window: window) + } } } return nil diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift index 8b6fbb8f23..d848007beb 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift @@ -9,7 +9,12 @@ extension RunnerTests { app.launch() defer { app.terminate() } XCTAssertTrue(app.switches["native-off"].waitForFixtureExistence(timeout: appExistenceTimeout)) - let resolved = ResolvedBlockingSystemModal(root: app, ownerApp: app, actions: actionableElements(in: app)) + let resolved = ResolvedBlockingSystemModal( + root: app, + ownerApp: app, + actions: actionableElements(in: app), + window: nil + ) let payload = try XCTUnwrap(try snapshotForBlockingSystemModal(resolved)) let off = try XCTUnwrap(payload.nodes?.first { $0.identifier == "native-off" }) let on = try XCTUnwrap(payload.nodes?.first { $0.identifier == "native-on" }) From e869aa51111d2b0d750301ef1d673136eb3862f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 28 Oct 2026 12:24:51 +0100 Subject: [PATCH 4/8] refactor(ios): place an alert against its host window in one rule The probe and the post-tap observation each decided whether a modal sits in the window hosting it. One pure rule now owns that decision, rejects non-finite frames, and judges a window against its own frame, so a dismiss popup window on a foldable's other panel is no longer read as absent. Co-Authored-By: Claude Opus 5.5 --- .../RunnerTests+AlertObservation.swift | 10 ++++------ .../RunnerTests+SynthesizedGesturePolicy.swift | 6 +----- .../RunnerTests+SystemModal.swift | 17 +++++++---------- .../RunnerTests+SystemModalTests.swift | 10 ++++++++++ 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift index 6cd7839d59..a96ce1ea9c 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift @@ -1,4 +1,5 @@ import XCTest +import AgentDeviceSnapshotPresentation extension RunnerTests { func captureAlertPresentation(_ element: XCUIElement) -> RunnerAlertPresentation? { @@ -53,7 +54,7 @@ extension RunnerTests { viewport: CGRect ) -> [XCUIElementSnapshot] { let frame = snapshot.frame - let visible = !frame.isNull && !frame.isEmpty && viewport.contains(CGPoint(x: frame.midX, y: frame.midY)) + let hostWindow = snapshot.elementType == .window && SnapshotGeometry.isPositiveFinite(frame) ? frame : viewport let matches: Bool switch source { case .blockingSystemModal: @@ -63,11 +64,8 @@ extension RunnerTests { case .dismissPopup: matches = snapshot.elementType == .window && containsDismissPopupMarker(snapshot) } - if matches && visible { return [snapshot] } - // A window is the viewport of what it hosts: a foldable's SpringBoard has a window on each - // panel, and the application frame names only one of them. - let childViewport = snapshot.elementType == .window && !frame.isNull && !frame.isEmpty ? frame : viewport - return snapshot.children.flatMap { alertSnapshots(in: $0, source: source, viewport: childViewport) } + if matches && Self.isPlaced(frame, in: hostWindow) { return [snapshot] } + return snapshot.children.flatMap { alertSnapshots(in: $0, source: source, viewport: hostWindow) } } private func containsDismissPopupMarker(_ snapshot: XCUIElementSnapshot) -> Bool { diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift index bd45b0d90b..99a1a4838c 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift @@ -198,11 +198,7 @@ extension SynthesizedCoordinateContext { resolvedWindow: XCUIElement?, accessibilityHealth: RunnerAccessibilityHealth ) { - guard referenceFrame.width.isFinite, referenceFrame.height.isFinite, - referenceFrame.width > 0, referenceFrame.height > 0 - else { - return nil - } + guard SnapshotGeometry.isPositiveFinite(referenceFrame) else { return nil } self.init( referenceFrame: referenceFrame, resolvedWindow: resolvedWindow, diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift index 59e2508c13..41e35882dc 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift @@ -159,17 +159,14 @@ extension RunnerTests { } private func isBlockingSystemModal(_ element: XCUIElement, in window: XCUIElement) -> Bool { - guard element.exists else { return false } - let frame = element.frame - if frame.isNull || frame.isEmpty { return false } - - let viewport = window.frame - if viewport.isNull || viewport.isEmpty { return false } - - let center = CGPoint(x: frame.midX, y: frame.midY) - if !viewport.contains(center) { return false } + element.exists && Self.isPlaced(element.frame, in: window.frame) + } - return true + /// Whether a modal is on screen in the window that hosts it. A foldable's SpringBoard has a + /// window on each panel, and the application frame names only one of them. + static func isPlaced(_ frame: CGRect, in hostWindow: CGRect) -> Bool { + SnapshotGeometry.isPositiveFinite(frame) && SnapshotGeometry.isPositiveFinite(hostWindow) + && hostWindow.contains(CGPoint(x: frame.midX, y: frame.midY)) } func actionableElements(in element: XCUIElement) -> [XCUIElement] { diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift index d848007beb..c78c5b46d9 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SystemModalTests.swift @@ -21,5 +21,15 @@ extension RunnerTests { XCTAssertEqual(off.value, "0") XCTAssertEqual(on.value, "1") } + + func testSpringBoardModalIsPlacedInItsOwnPanelWindow() { + let outerPanel = CGRect(x: 0, y: 0, width: 466, height: 678) + let innerPanel = CGRect(x: 0, y: 0, width: 951, height: 669) + let innerPanelAlert = CGRect(x: 341, y: 250, width: 270, height: 170) + XCTAssertTrue(Self.isPlaced(innerPanelAlert, in: innerPanel)) + XCTAssertFalse(Self.isPlaced(innerPanelAlert, in: outerPanel)) + XCTAssertFalse(Self.isPlaced(innerPanelAlert, in: CGRect(x: 0, y: 0, width: CGFloat.infinity, height: 669))) + XCTAssertFalse(Self.isPlaced(.zero, in: innerPanel)) + } #endif } From 9ceab4561c26a36c3025a7a6a4b5456b4f797420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 28 Oct 2026 12:24:51 +0100 Subject: [PATCH 5/8] =?UTF-8?q?fix(ios):=20answer=20Safari's=20"Open=20thi?= =?UTF-8?q?s=20page=20in=20=E2=80=A6=3F"=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Safari draws its page prompts as an SFDialogView, not an alert, so `alert` reported "alert not found" while the prompt was on screen, on every iPhone. The runner now finds the dialog by that identifier and verifies its answer against the same surface. Co-Authored-By: Claude Opus 5.5 --- .../AgentDeviceRunnerUITests/RunnerTests+Alert.swift | 10 ++++++++++ .../RunnerTests+AlertObservation.swift | 2 ++ website/docs/docs/commands.md | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift index c4c6742414..880e7ad563 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift @@ -4,6 +4,7 @@ extension RunnerTests { enum RunnerAlertSource { case blockingSystemModal case appAlert + case safariDialog case dismissPopup } @@ -56,6 +57,11 @@ extension RunnerTests { if let alert = firstExistingElement(in: safeElementsQuery { activeApp.alerts.allElementsBoundByIndex }) { return runnerAlert(root: alert, ownerApp: activeApp, source: .appAlert) } + if let dialog = firstExistingElement(in: safeElementsQuery { + activeApp.otherElements.matching(identifier: Self.safariDialogIdentifier).allElementsBoundByIndex + }) { + return runnerAlert(root: dialog, ownerApp: activeApp, source: .safariDialog) + } if let popup = firstDismissPopupWindow(in: activeApp) { return runnerAlert(root: popup, ownerApp: activeApp, source: .dismissPopup) } @@ -262,6 +268,10 @@ extension RunnerTests { elements.first { isVisibleElement($0) } } + /// Safari draws its page prompts, such as "Open this page in …?" and JavaScript dialogs, as a + /// view rather than an alert, so they are found by the view's identifier. + static let safariDialogIdentifier = "SFDialogView" + /// The marker is matched inside XCTest's query, so the screen is read once per query. Reading each /// descendant instead costs one round trip per element, and on a screen whose tree changes while /// it is read (a loading web view) each vanished element adds XCTest's retry cycle. `containing` diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift index a96ce1ea9c..8d63166cea 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift @@ -61,6 +61,8 @@ extension RunnerTests { matches = snapshot.elementType == .alert || snapshot.elementType == .sheet case .appAlert: matches = snapshot.elementType == .alert + case .safariDialog: + matches = snapshot.identifier == Self.safariDialogIdentifier case .dismissPopup: matches = snapshot.elementType == .window && containsDismissPopupMarker(snapshot) } diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index 734eef3869..2130e7b8b2 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -434,7 +434,7 @@ agent-device alert dismiss - `wait_stable_timeout`: the UI did not settle. - Branch on `readableCaptures`, `waitedMs`, `matches`, and `firstMatch` instead of parsing error text. `firstMatch` carries identity and text only; absence failures make no visibility or rect claim. - Polling wait timeouts, and a replayed wait refused with `wait_landmark_identity_mismatch`, also carry `captures`, `readableCaptures`, and `polls` so you can see where the budget went. Each poll has `startedMs`, `durationMs`, and an `outcome`: `readable`, `unreadable`, `retriable`, `deadline`, `runner-restart`, or `readiness`. Long waits keep the first 5 and last 25 polls. A wait that never saw a readable capture reports the error its polls hit, with that error's code and retry details, instead of a generic timeout; `wait stable` and a never-readable strict absence keep their own diagnostics. `logPath` links the full request log. -- `alert` (same as `alert get`) inspects or handles system alerts on iOS simulator, macOS desktop, and Android permission dialogs. On iOS it also covers app-owned modal popups with native blocking markers. The `[timeout]` argument applies to `alert wait` only, on every backend: `alert wait ` takes a budget up to 2147483647 ms (~24.8 days), larger is refused as `INVALID_ARGS` before anything runs, while `get`/`accept`/`dismiss` run their own fixed per-backend budgets and ignore it. +- `alert` (same as `alert get`) inspects or handles system alerts on iOS simulator, macOS desktop, and Android permission dialogs. On iOS it also covers app-owned modal popups with native blocking markers, and Safari's own page prompts, such as "Open this page in …?". The `[timeout]` argument applies to `alert wait` only, on every backend: `alert wait ` takes a budget up to 2147483647 ms (~24.8 days), larger is refused as `INVALID_ARGS` before anything runs, while `get`/`accept`/`dismiss` run their own fixed per-backend budgets and ignore it. - On the snapshot-derived backends (Android, Limrun iOS) `alert get --json` answers with a typed `status`: `visible`, `none`, or `undecided` (an alert-shaped capture that resolves to no single alert). Branch on `status`, not on the message. - On those backends, `alert accept` presses the lasting grant when a permission sheet offers several: Android orders its grants by the platform's own ids (full-access "Allow all", then foreground-only, then always, then the picker-limited "Select photos and videos", then one-time) whatever the button language — this is what makes the Android 14+ partial-media sheet answer "Allow all" — and elsewhere the English label table decides ("while using the app" over "only this time"). Android acts only on the grant ids it declares with a role and a rank; a sheet carrying an allow- or deny-shaped grant id it does not declare (a vendor fork's own button, or a newer Android grant) is refused for both `accept` and `dismiss` — `dismiss` answers with the Back key, the cancel that grants nothing. A sheet whose choices no rank orders — or that names the same choice at two points — is refused with `alert_button_undecided` and `dispatched: no`, never pressed by position; read the labels with `alert get` and press your choice by label/ref. - On those backends, when `alert accept`/`dismiss` fails before pressing anything, `error.details.reason` names why (a capture or transport failure that is not a driver refusal may instead surface as its own error without a `reason`). A budget never cancels a running capture or press: it only ends the polling loop, so every check that started inside the budget finishes and counts. Before any press, `dispatched: no` and the reason is `alert-not-found` (the action budget ended with no alert on screen), `alert_capture_undecided`, or `alert_button_undecided` (the sheet is too ambiguous to act on). After a press, `dispatched` is absent and the reason is `alert-window-expired`; “did not dismiss the visible alert” means the latest post-press capture that answered named the same dialog again, “could not be confirmed” means the press went out but the latest read was unresolvable or never answered, so the dialog may already be gone. If you cancel the request at any point from the press onward — the tap in flight, or the post-press checks — the cancellation reports `dispatched: unknown`: the device may already have received the tap. The one exception is a cancel whose post-press check nevertheless finished and proved the alert gone; then the command reports the handled alert, because the outcome is known. Run `alert get` before acting again. From 6e7ad515a3d8d5c6887682098151163a67ae7705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 28 Oct 2026 12:36:56 +0100 Subject: [PATCH 6/8] docs(alert): name Safari page prompts in the alert help Co-Authored-By: Claude Opus 5.5 --- src/commands/schema/cli-help-workflows.ts | 2 +- website/docs/docs/commands.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/schema/cli-help-workflows.ts b/src/commands/schema/cli-help-workflows.ts index 8db8856d9b..7958f4b388 100644 --- a/src/commands/schema/cli-help-workflows.ts +++ b/src/commands/schema/cli-help-workflows.ts @@ -124,7 +124,7 @@ Alerts: agent-device alert wait 3000 agent-device alert accept agent-device alert dismiss - Android support is snapshot-derived for runtime permission prompts and native app dialogs. iOS support is runner-derived for XCTest alerts, app-owned modal popups with native blocking markers, and blocking system dialogs. Use cheap alert get for an immediate check; use alert wait only when a prompt may appear after async work. + Android support is snapshot-derived for runtime permission prompts and native app dialogs. iOS support is runner-derived for XCTest alerts, app-owned modal popups with native blocking markers, Safari page prompts such as "Open this page in …?", and blocking system dialogs. Use cheap alert get for an immediate check; use alert wait only when a prompt may appear after async work. If alert says no alert but a sheet is visibly on screen, treat it as app-owned UI: agent-device snapshot -i agent-device press 'label="Allow"' diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index 2130e7b8b2..2bf8d26ec2 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -434,7 +434,7 @@ agent-device alert dismiss - `wait_stable_timeout`: the UI did not settle. - Branch on `readableCaptures`, `waitedMs`, `matches`, and `firstMatch` instead of parsing error text. `firstMatch` carries identity and text only; absence failures make no visibility or rect claim. - Polling wait timeouts, and a replayed wait refused with `wait_landmark_identity_mismatch`, also carry `captures`, `readableCaptures`, and `polls` so you can see where the budget went. Each poll has `startedMs`, `durationMs`, and an `outcome`: `readable`, `unreadable`, `retriable`, `deadline`, `runner-restart`, or `readiness`. Long waits keep the first 5 and last 25 polls. A wait that never saw a readable capture reports the error its polls hit, with that error's code and retry details, instead of a generic timeout; `wait stable` and a never-readable strict absence keep their own diagnostics. `logPath` links the full request log. -- `alert` (same as `alert get`) inspects or handles system alerts on iOS simulator, macOS desktop, and Android permission dialogs. On iOS it also covers app-owned modal popups with native blocking markers, and Safari's own page prompts, such as "Open this page in …?". The `[timeout]` argument applies to `alert wait` only, on every backend: `alert wait ` takes a budget up to 2147483647 ms (~24.8 days), larger is refused as `INVALID_ARGS` before anything runs, while `get`/`accept`/`dismiss` run their own fixed per-backend budgets and ignore it. +- `alert` (same as `alert get`) inspects or handles system alerts on iOS simulator, macOS desktop, and Android permission dialogs. On iOS it also covers app-owned modal popups with native blocking markers. On the Apple XCUITest runner it also covers Safari's own page prompts, such as "Open this page in …?". The `[timeout]` argument applies to `alert wait` only, on every backend: `alert wait ` takes a budget up to 2147483647 ms (~24.8 days), larger is refused as `INVALID_ARGS` before anything runs, while `get`/`accept`/`dismiss` run their own fixed per-backend budgets and ignore it. - On the snapshot-derived backends (Android, Limrun iOS) `alert get --json` answers with a typed `status`: `visible`, `none`, or `undecided` (an alert-shaped capture that resolves to no single alert). Branch on `status`, not on the message. - On those backends, `alert accept` presses the lasting grant when a permission sheet offers several: Android orders its grants by the platform's own ids (full-access "Allow all", then foreground-only, then always, then the picker-limited "Select photos and videos", then one-time) whatever the button language — this is what makes the Android 14+ partial-media sheet answer "Allow all" — and elsewhere the English label table decides ("while using the app" over "only this time"). Android acts only on the grant ids it declares with a role and a rank; a sheet carrying an allow- or deny-shaped grant id it does not declare (a vendor fork's own button, or a newer Android grant) is refused for both `accept` and `dismiss` — `dismiss` answers with the Back key, the cancel that grants nothing. A sheet whose choices no rank orders — or that names the same choice at two points — is refused with `alert_button_undecided` and `dispatched: no`, never pressed by position; read the labels with `alert get` and press your choice by label/ref. - On those backends, when `alert accept`/`dismiss` fails before pressing anything, `error.details.reason` names why (a capture or transport failure that is not a driver refusal may instead surface as its own error without a `reason`). A budget never cancels a running capture or press: it only ends the polling loop, so every check that started inside the budget finishes and counts. Before any press, `dispatched: no` and the reason is `alert-not-found` (the action budget ended with no alert on screen), `alert_capture_undecided`, or `alert_button_undecided` (the sheet is too ambiguous to act on). After a press, `dispatched` is absent and the reason is `alert-window-expired`; “did not dismiss the visible alert” means the latest post-press capture that answered named the same dialog again, “could not be confirmed” means the press went out but the latest read was unresolvable or never answered, so the dialog may already be gone. If you cancel the request at any point from the press onward — the tap in flight, or the post-press checks — the cancellation reports `dispatched: unknown`: the device may already have received the tap. The one exception is a cancel whose post-press check nevertheless finished and proved the alert gone; then the command reports the handled alert, because the outcome is known. Run `alert get` before acting again. From 8cf03e5d29991c8482997f606b9bc7df2fc636cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 30 Oct 2026 20:59:37 +0100 Subject: [PATCH 7/8] test(ios): pin which node a Safari dialog observation matches Co-Authored-By: Claude Opus 5.5 --- .../RunnerTests+AlertObservation.swift | 2 +- .../RunnerTests+AlertObservationTests.swift | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift index 8d63166cea..11397272f5 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift @@ -48,7 +48,7 @@ extension RunnerTests { return Date() < deadline ? observation : .deadlineExceeded } - private func alertSnapshots( + func alertSnapshots( in snapshot: XCUIElementSnapshot, source: RunnerAlertSource, viewport: CGRect diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift index 87b7bdae2f..a40626b313 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift @@ -294,5 +294,17 @@ extension RunnerTests { XCTAssertEqual(inspection.data?.items?.sorted(), ["Cancel", "OK"]) XCTAssertEqual(app.staticTexts["agent-device-alert-actions"].label, "First actions: 1; replacement actions: 0") } + + @MainActor + func testSafariDialogObservationMatchesOnlyTheDialogView() { + let dialog = ElementAttributesFixture(.other, CGRect(x: 20, y: 300, width: 360, height: 120), identifier: Self.safariDialogIdentifier) + let alert = ElementAttributesFixture(.alert, CGRect(x: 20, y: 500, width: 360, height: 120)) + let window = ElementAttributesFixture(.window, CGRect(x: 0, y: 0, width: 402, height: 874), children: [alert, dialog]) + XCTAssertEqual( + alertSnapshots(in: window, source: .safariDialog, viewport: window.frame).map(\.identifier), + [Self.safariDialogIdentifier] + ) + XCTAssertEqual(alertSnapshots(in: window, source: .appAlert, viewport: window.frame).map(\.elementType), [.alert]) + } #endif } From 428c5ff490aebcfac9a3932be2b3269501e40054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 30 Oct 2026 21:45:44 +0100 Subject: [PATCH 8/8] test(ios): reject an unrelated view in the Safari dialog observation test Co-Authored-By: Claude Opus 5.5 --- .../UnitTests/RunnerTests+AlertObservationTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift index a40626b313..ac603efae3 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+AlertObservationTests.swift @@ -299,7 +299,8 @@ extension RunnerTests { func testSafariDialogObservationMatchesOnlyTheDialogView() { let dialog = ElementAttributesFixture(.other, CGRect(x: 20, y: 300, width: 360, height: 120), identifier: Self.safariDialogIdentifier) let alert = ElementAttributesFixture(.alert, CGRect(x: 20, y: 500, width: 360, height: 120)) - let window = ElementAttributesFixture(.window, CGRect(x: 0, y: 0, width: 402, height: 874), children: [alert, dialog]) + let page = ElementAttributesFixture(.other, CGRect(x: 0, y: 100, width: 402, height: 600), identifier: "WebView") + let window = ElementAttributesFixture(.window, CGRect(x: 0, y: 0, width: 402, height: 874), children: [page, alert, dialog]) XCTAssertEqual( alertSnapshots(in: window, source: .safariDialog, viewport: window.frame).map(\.identifier), [Self.safariDialogIdentifier]