Repository navigation
feat(webdriverio): add hide, remove and selector masks - #406
Merged
gregberge merged 1 commit intoOct 21, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
gregberge
force-pushed
the
greg/arg-520-ignore-regions-in-screenshot-comparisons
branch
from
October 21, 2026 08:16
cd9b9f3 to
8d11d98
Compare
Bring the WebdriverIO SDK to parity with the other SDKs for hiding regions. `argosScreenshot` now injects the Argos browser script and runs its core plugins only (`__argos__` class, `argosCSS`, `data-visual-test` helpers), so no stabilization waits are added. The page is restored after the screenshot. - `hide` and `remove` take WebdriverIO selectors and apply the `transparent` and `removed` helpers to the matched elements. Removing wins over hiding. - `mask` also takes selectors. Their areas are measured in the viewport, which is what `saveScreenshot` captures, and scaled by the device pixel ratio. Elements with `data-visual-test="blackout"` are always masked, as with Playwright and Cypress. Areas are clipped to the screenshot. - `argosCSS` injects custom CSS during the screenshot. Existing `data-visual-test` attributes now take effect, so screenshots of pages using them will change. The e2e runner resolves the built `@argos-ci/*` packages, as the browser script is only embedded at build time. Refs ARG-520 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gregberge
force-pushed
the
claude/webdriverio-hide-remove
branch
from
October 21, 2026 08:25
ccd41e9 to
99afa73
Compare
gregberge
merged commit Oct 21, 2026
612ffe5
into
greg/arg-520-ignore-regions-in-screenshot-comparisons
2 checks passed
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #403. Brings
@argos-ci/webdriverioto parity with the other SDKs for hiding regions (ARG-520).Before this PR, the WebdriverIO SDK never injected the Argos browser script, so
data-visual-testattributes did nothing. Now they take effect:data-visual-test="transparent"hides the elementdata-visual-test="removed"removes the element from the layoutdata-visual-test="blackout"masks the element withmaskColorExisting WebdriverIO users whose pages already use these attributes will see their screenshots change. This is worth mentioning in the release notes.
Changes
argosScreenshotinjects the global script and runs the lifecycle withoptions: false, so only the core plugins run (__argos__class,argosCSS, helper CSS) and no stabilization waits are added. The order matches the other SDKs:beforeAll → applyHelper → beforeEach → capture → afterEach/afterAll.hide?: string[]andremove?: string[]: selectors are resolved withbrowser.$$, so every WebdriverIO selector strategy works, and the matches go to__ARGOS__.applyHelper, which keeps the strongest helper per element. Selectors that match nothing are ignored.maskalso accepts selectors ((string | { x, y, width, height })[]). Element areas come fromgetBoundingClientRect(), which is relative to the viewport (allsaveScreenshotcaptures), and are scaled bydevicePixelRatio. They are measured afterhide/removeapply, since removal shifts the layout.[data-visual-test="blackout"]is always masked, as with Playwright'smaskand Cypress'sblackout. All areas are now clipped to the image, so an element taller than the viewport no longer makes sharp throw.argosCSSis exposed, since the coreaddArgosCSSplugin already runs.@argos-ci/browseris added as a dependency.Round trips
WebdriverIO commands are remote round trips (often to a grid), so they are batched:
hide/removeselectors are resolved while the script is injectedbeforeAll, the helpers andbeforeEachrun in oneexecuteA screenshot with no options now sends 5 commands (inject, setup, find blackout, take screenshot, teardown). Before this PR it sent 1. With
hide/remove/maskselectors, it takes 6 sequential round trips.Masks are composited onto the screenshot in a single sharp pass, and the file is written as-is, with no re-encode.
Tests
New e2e specs in
test/specs/test.e2e.tswith afixtures/helpers.htmlpage. They read pixels from the saved PNGs to check:data-visual-testhelpers apply, and the page is restored afterwards (class, attributes, CSS)hide/remove, including "remove wins" and selectors that match nothingmaskColorbrowser.setViewportargosCSSwdio.conf.tspoints tsx at the roottsconfig.build.json, which clears thepathsalias. Without it, tsx loads@argos-ci/browserfromsrc, wheregetGlobalScript()isundefinedbecause the script is only embedded at build time. Turbo already builds the package beforee2e.Verified locally:
pnpm exec turbo run check-types lint check-format test --filter=@argos-ci/webdriverio: greenpnpm run test-e2e: 9 passing (WebDriver BiDi, Chrome 156)wdio:enforceWebDriverClassic: true: 8 passing (the 2× test needs BiDi'ssetViewport). This covers the classicexecuteargument serialization used by wdio 6–8.Open question: sharp masks vs the
__ARGOS__.maskoverlay (#404)#404 adds an in-page
__ARGOS__.mask(elements, color)overlay for Puppeteer. Masking in the page would remove the viewport/DPR/clipping logic here, would work inside iframes and with drivers that capture more than the viewport, and would keep blackout consistent across SDKs. If WebdriverIO later moves from sharp to that overlay, masked areas will change slightly (whole-pixel vs anti-aliased edges), so users would see diffs twice. Consider landing #404 first and switching selector and blackout masks to it here before release.Not included
Elementobjects inhide/remove/mask(Puppeteer and Playwright accept handles); only selectors for now.stabilize, waits, viewports, metadata) is still Playwright/Puppeteer only.sdks-reference/webdriverio,argos-helpers) should be updated with the other SDKs once this ships.🤖 Generated with Claude Code