Skip to content

feat: register the swipe routes on watchOS - #1257

Open
ThiagoLannes wants to merge 1 commit into
appium:masterfrom
ThiagoLannes:feat/watchos-swipe-route
Open

feat: register the swipe routes on watchOS#1257
ThiagoLannes wants to merge 1 commit into
appium:masterfrom
ThiagoLannes:feat/watchos-swipe-route

Conversation

@ThiagoLannes

Copy link
Copy Markdown

On watchOS POST /wda/swipe and POST /wda/element/:uuid/swipe return 404 Unhandled endpoint, so mobile: swipe is unavailable through the XCUITest driver.

They are registered only inside the #elif !TARGET_OS_WATCH branch of FBElementCommands.routes, under a comment stating that gesture synthesis is not supported on watchOS. That is accurate for the routes which synthesise events — but swipe does not synthesise anything:

  • XCUIElement.h in the WatchSimulator SDK declares swipeUp, swipeDown, swipeLeft, swipeRight and the WithVelocity: variants with no watchOS exclusion. Only the tap family carries API_UNAVAILABLE(tvos).
  • -[XCUIElement fb_swipeWithDirection:velocity:] invokes those methods by selector, and XCUIElement+FBSwiping.m carries no TARGET_OS_WATCH guard — it is already compiled into the watchOS target.
  • handleSwipe: lives in the non-tvOS branch of the implementation, so it is compiled there too.

The capability is therefore already present on watchOS and only the route registration was missing. This adds it in a #if TARGET_OS_WATCH block and reworks the neighbouring comment so it no longer implies swipe is impossible there.

Verification

Paired Apple Watch Series 11 (46mm) / watchOS 26.5 simulator, appium-xcuitest-driver 12.8.0, real watch app.

POST /wda/swipe
before 404 {"error":"unknown command","message":"Unhandled endpoint: …/wda/swipe"}
after 200, and the swipe turns a SwiftUI TabView(.page)

Six UI tests that could not run — the app under test puts its in-round screens on a horizontal pager, so only the initially-selected page was reachable — now pass.

Scope

W3C actions stay unavailable on watchOS: fb_performW3CActions: is compiled out along with the rest of the touch-synthesis stack (XCUIApplication+FBTouchAction.m, FBW3CActionsSynthesizer.m, FBBaseActionsSynthesizer.m are each guarded #if !TARGET_OS_TV && !TARGET_OS_WATCH). This change deliberately does not touch that — it only exposes the native swipe that is already built.

Happy to add a functional test under the existing watchOS CI job if you would like one.

`/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.
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@mykola-mokhnach

Copy link
Copy Markdown

thanks @ThiagoLannes
Could you please sign the CLA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants