Skip to content

skip_area masks what exists NOW — surface selectors that never match #277

Description

@pftg

Follow-up to #272, raised by the maintainer: removing the implicit wait fixed a measured 44% of a suite, but that wait was doing a second job by accident.

The risk the fix created

A skip_area mask is only correct if the element exists when the mask is computed. Capybara's minimum: 1 default meant a not-yet-present element got up to 5s to appear. With minimum: 0, a lazy-loaded image that has not arrived yields an empty mask — nothing is excluded, the unstable region is compared, and the test flakes.

At risk: lazy-loaded images below the fold (skip_area: ["article img"]), JS-injected widgets and embeds, anything behind an unresolved fetch. Not at risk: elements already in the DOM, which resolved in ~0.008s before and after.

The trade is still right — the cost was certain and large, the risk is narrow and addressable — but it is real, and right now it fails silently.

What a real consumer already does

def preload_all_images
  scroll_to :bottom
  assert_text "JetThoughts. All Rights Reserved", exact: false
  scroll_to :top
end

called on the line before the screenshot, plus document.fonts.ready in their wrapper. This works today and needs nothing from us.

Considered and rejected: a before_capture block

assert_matches_screenshot("x") { preload_all_images } is functionally identical to calling the method on the previous line — the work happens once before capture either way. It adds API surface and buys nothing.

Worth revisiting only if a case appears that must run inside the stability retry loop, which is the one thing a block could do that a preceding line cannot. No such case is known.

What to build instead

Decision recorded at .okf/decisions/skip-area-element-readiness.md with the options weighed.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions