Skip to content

Native mobile support is WDIO-only: no other adapter can detect a native session #372

Description

@vishnuv688

#345#350 built native mobile capture, but the split between what of it is cross-adapter and what is not was never stated. The trace and player halves are cross-adapter; every adapter-side piece is WDIO-only, because the WDIO service is the only adapter that can tell a native session from a browser one.

Neither Selenium, Nightwatch nor the Python adapter claims native support today, so this is not a regression — it is an unimplemented case, and this issue is to close it.

Already cross-adapter — no work needed

Recorded here so nobody re-does it:

WDIO-only

isNativeMobile exists in exactly one file, packages/service/src/mobile.ts, and reads browser.isMobile / isAndroid / isIOS — runtime flags WDIO derives for its own browser object. Selenium's WebDriver, Nightwatch's browser and the Python driver have no equivalent.

Fourteen call sites in the service gate on it. Each one protects a page-side call that cannot work without a document:

what it protects site
the whole page drain session.ts captureTrace
the drain and performance read after a page-transition command session.ts:188
the per-command screenshot session.ts:165
collector injection at bringup index.ts:243
the live-command drain index.ts:674
reading the viewport with getWindowSize() rather than window.visualViewport session-metadata.ts:32
the per-action snapshot: skip the settle, and take the native path (getPageSource instead of runScript) action-snapshot.ts:76, :111
the assertion screenshot assertion-tracker.ts:122

The other adapters have the same-named methods and gate none of them:

  • selenium-devtools: session.ts captureTrace / injectScript / takeScreenshot / captureBrowserLogs / reinjectIfNavigated, session-lifecycle.ts registerPreload, helpers/commandPostActions.ts capturePerformance, action-snapshot.ts.
  • nightwatch-devtools: session.ts captureTrace / injectScript / anchorAfterNavigation / captureBrowserLogs / captureNetworkFromPerformanceLogs, and the four helpers/webdriverHttp.ts probes.
  • selenium-devtools-py: instrumentation.py _viewport reads window.innerWidth/Height unconditionally; snapshot.py _DRAIN_SCRIPT likewise.

Selenium reads platformName in one place — a boot log line in helpers/driverMetadata.ts. Nightwatch's isMobile/isAndroid/isIOS appear only as entries in INTERNAL_COMMANDS_TO_IGNORE, which is its own commands being filtered out of the action list, not detection. Python has no reference to platformName at all.

Consequences, measured

  1. A Selenium or Nightwatch native trace claims viewport: 1280x720 — the exporter's fallback — so the player frames a phone at desktop proportions. device is still correct, so the device layout selects; it is the geometry inside it that is wrong.
  2. Either adapter would emit the failures Wasted Appium round trips: captureTrace runs on native sessions #350 just removed from the service: Method is not implemented, once per drain. On the service that was five per run, at ERROR, in the user's output.
  3. Python the same, at DEBUG.

The shared piece

A native-session predicate in packages/core — all three JS adapters may import core, and shared's isNativePlatform / deviceFromCapabilities already do the narrowing the exporter needs. It must read capabilities, not driver flags: capabilities are the one thing all four adapters have.

One constraint to settle before implementing, because it is not obvious: isNativePlatform(platformName) alone is the wrong predicate. WDIO's own isMobile deliberately returns false when automationName is gecko/safari/chrome/chromium (see @wdio/utils), i.e. it excludes mobile web. An Android Chrome session reports platformName: 'Android' and has a DOM — gating the drain on the platform alone would silently kill DOM capture for it, turning a fix into a worse bug than the one it fixes. The predicate has to reject a session that names a browser automation.

That is also why the app already splits the two questions, and should stay as it is: workbench.ts #deviceLayout gates on device alone (a mobile browser session is still a portrait viewport that wants the tall column, it just keeps its address bar inside it), while snapshot.ts #deviceCapture additionally requires no mutations and no metadata.url before it draws device chrome.

Scope

  • core: a native-session predicate reading capabilities, with the mobile-web exclusion above, unit-tested against real capability bags from both cases (local Appium, a device cloud, and Android Chrome).
  • service: isNativeMobile delegates to it. The runtime-flag read can stay as a fast path — those flags are what WDIO already computed — but the answer should come from one place.
  • selenium-devtools: gate the sites listed above. Put the guard inside the function, not at the call sites — Wasted Appium round trips: captureTrace runs on native sessions #350's finding was that two of four call sites asked and two forgot.
  • nightwatch-devtools: same.
  • selenium-devtools-py: guard _viewport and the drain; read the window size off the driver on native.
  • every adapter reads the viewport the native way, so a native trace carries the device's real size rather than the 1280x720 fallback.
  • a native example per adapter, or an explicit line in each README saying native is unsupported there.

Verification needs real devices or a device cloud; CI cannot cover it, so the PR should state what was run and on what.

Related

Activity

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

Metadata

Metadata

Assignees

Labels

capture-architectureCross-language capture architectureenhancementNew feature or requestmobileAppium / native mobile capture and playback

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions