From d9425b23b26d786cc0a17abaca025ed6a69b4a28 Mon Sep 17 00:00:00 2001 From: Thiago Lannes Date: Thu, 10 Sep 2026 17:01:50 +0100 Subject: [PATCH] feat: register the swipe routes on watchOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `/wda/element/:uuid/swipe` and `/wda/swipe` are currently registered only in the `#elif !TARGET_OS_WATCH` branch of `FBElementCommands.routes`, under a comment saying gesture synthesis is not supported on watchOS. That is true of the routes that synthesise events, but swipe does not synthesise anything: * `XCUIElement.h` in the WatchSimulator SDK declares `swipeUp`, `swipeDown`, `swipeLeft`, `swipeRight` and their `WithVelocity:` variants with no watchOS exclusion — only the taps carry `API_UNAVAILABLE(tvos)`. * `-[XCUIElement fb_swipeWithDirection:velocity:]` invokes those methods by selector, and `XCUIElement+FBSwiping.m` has no `TARGET_OS_WATCH` guard, so it is already compiled into the watchOS target. * `handleSwipe:` itself is in the non-tvOS branch, so it is already compiled there too. So the capability is present and only the registration was missing: on watchOS `mobile: swipe` returns `404 Unhandled endpoint`. Verified on a paired Apple Watch Series 11 (46mm) / watchOS 26.5 simulator with appium-xcuitest-driver 12.8.0. Before: `POST /wda/swipe` -> 404 "Unhandled endpoint". After: 200, and a horizontal swipe turns a SwiftUI `TabView(.page)` in a real watch app. Six UI tests that had been unrunnable because the app's in-round screens are a horizontal pager now pass. W3C actions remain unavailable on watchOS (`fb_performW3CActions:` is compiled out with the rest of the touch-synthesis stack) and this change does not touch that. --- WebDriverAgentLib/Commands/FBElementCommands.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WebDriverAgentLib/Commands/FBElementCommands.m b/WebDriverAgentLib/Commands/FBElementCommands.m index a46958bce..b41b7c2f0 100644 --- a/WebDriverAgentLib/Commands/FBElementCommands.m +++ b/WebDriverAgentLib/Commands/FBElementCommands.m @@ -74,7 +74,8 @@ + (NSArray *)routes [[FBRoute GET:@"/element/:uuid/attribute/focused"] respondWithTarget:self action:@selector(handleGetFocused:)], [[FBRoute POST:@"/wda/element/:uuid/focuse"] respondWithTarget:self action:@selector(handleFocuse:)], #elif !TARGET_OS_WATCH - // Gesture synthesis isn't supported on watchOS - only /element/:uuid/click is available. + // Gesture synthesis isn't supported on watchOS; the routes below all rely on it. Swipe is + // the exception and is registered for watchOS separately, at the end of this list. [[FBRoute POST:@"/wda/element/:uuid/swipe"] respondWithTarget:self action:@selector(handleSwipe:)], [[FBRoute POST:@"/wda/swipe"] respondWithTarget:self action:@selector(handleSwipe:)], @@ -116,6 +117,13 @@ + (NSArray *)routes [[FBRoute POST:@"/wda/tap"] respondWithTarget:self action:@selector(handleTap:)], [[FBRoute POST:@"/wda/pickerwheel/:uuid/select"] respondWithTarget:self action:@selector(handleWheelSelect:)], +#endif +#if TARGET_OS_WATCH + // Swiping does not need gesture synthesis: XCUIElement declares swipeUp/Down/Left/Right on + // watchOS, and -fb_swipeWithDirection:velocity: calls them directly. handleSwipe: is already + // compiled here (it lives in the non-tvOS branch below), so only the route was missing. + [[FBRoute POST:@"/wda/element/:uuid/swipe"] respondWithTarget:self action:@selector(handleSwipe:)], + [[FBRoute POST:@"/wda/swipe"] respondWithTarget:self action:@selector(handleSwipe:)], #endif [[FBRoute POST:@"/wda/keys"] respondWithTarget:self action:@selector(handleKeys:)], ];