Skip to content

Selenium and Nightwatch traces are framed at 1280x720: neither adapter publishes a viewport #373

Description

@vishnuv688

Neither the Selenium nor the Nightwatch adapter publishes a viewport at all — grep -rn "viewport" packages/selenium-devtools/src packages/nightwatch-devtools/src returns nothing. So trace.metadata.viewport is absent for every trace either one produces, and the reader falls back to a hard-coded default in three places (packages/trace/src/trace-exporter.ts:190, :318, :367):

const viewport = trace.metadata.viewport ?? { width: 1280, height: 720 }

That default is what the player lays the DOM-replay iframe out at (packages/app/src/components/browser/snapshot.ts:309viewport?.width || 1280), so every Selenium and Nightwatch trace is replayed at 1280x720 regardless of the window the run actually used. It is not a mobile-only problem; a desktop run at 2560x1440 is framed just as wrongly, which is presumably why it went unnoticed — the proportions are plausible.

The WDIO service and the Python adapter both do this already, and they show what it takes:

  • packages/service/src/session-metadata.ts resolveViewport — reads window.visualViewport for a page (it carries the real scale and offsets, unlike the driver window, which includes browser chrome) and getWindowSize() for a native app, degrading to no viewport rather than failing the session.
  • packages/selenium-devtools-py/src/selenium_devtools/instrumentation.py _viewport / _driver_window — the same split, with the read marked internal so it does not re-enter the command hook as a captured executeScript/getWindowRect row. Both adapters here would need that same care: Selenium's unpatched getDriverOriginals(), Nightwatch's raw webdriverHttp transport.

isNativeAppSession (shared) already answers which of the two reads applies, so the branch is settled — this is the read itself plus its plumbing into each adapter's metadata.

Worth doing in the same change: metadata.viewport is documented as "metadata only" in a couple of places, and it is not — it is load-bearing geometry wherever there is DOM to replay. Whichever comment survives should say so.

Split out of #372, which covered native detection and deliberately stopped short of this.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcapture-architectureCross-language capture architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions