Skip to content

Align label, strict locator, and URL wait semantics - #2895

Open
miguelg719 wants to merge 10 commits into
evals/consolidation-04-cdp-diagnosticsfrom
evals/consolidation-05-locator-wait-contract
Open

Align label, strict locator, and URL wait semantics#2895
miguelg719 wants to merge 10 commits into
evals/consolidation-04-cdp-diagnosticsfrom
evals/consolidation-05-locator-wait-contract

Conversation

@miguelg719

@miguelg719 miguelg719 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Aligns the shared facade’s label matching, strict locator operations and URL waits with supported Playwright behavior. All consuming harnesses get these semantics through the same facade.

Adds local-browser comparisons against native Playwright alongside deterministic URL-wait tests. Frame composition is isolated in the next change.

Checkbox probes share the operation timeout; nested role filters are resolved before matching. The real DOM contract suite is registered in Turbo.

Validation: 111 core tests, three real-Chrome DOM tests, package build/typecheck and formatting; Locator/wait units and local Chrome versus Playwright contract probes.

Stack position: 5/17. Base: evals/consolidation-04-cdp-diagnostics. Each PR contains the change relative to its immediate predecessor.

Reviewer entry points:

Readiness: local validation is described above; GitHub CI and automated review feedback are pending. This PR is open as non-draft so automated reviewers can run.

@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0613e13

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Architecture diagram
sequenceDiagram
    participant T as Test Harness
    participant F as Facade Runtime
    participant L as Raw Locator
    participant P as Raw Page
    participant B as Browser/CDP
    participant PW as Native Playwright

    Note over T,PW: Core Facade Alignment Flow

    T->>F: getByLabel(label, {exact})
    F->>B: Query DOM for labels (labelledby > aria-label > label)
    B-->>F: Matching elements
    F-->>T: Locator with matches
    
    alt Strict mode violation (multiple matches)
        T->>F: locator.textContent({timeout})
        F->>B: Detect multiple candidates
        B-->>F: Ambiguous elements
        F-->>T: Throw strict mode violation with candidates
    end

    T->>F: locator.inputValue({timeout})
    F->>L: Query strict single match
    L->>B: Wait for element
    alt Element appears
        B-->>L: Single element
        L-->>F: Value
        F-->>T: Return value
    else Element missing
        B-->>L: Not found
        L-->>F: Timeout error
        F-->>T: Throw timeout
    end

    T->>F: getByRole(role, {name})
    F->>B: DOM role matching
    alt No DOM matches
        F->>P: page.snapshot() - accessibility tree
        P-->>F: Formatted tree + xpathMap
        F->>F: Resolve role to XPaths
        F->>L: Apply xpath steps
        L-->>F: Elements
    end
    F-->>T: Locator result

    T->>F: waitForURL(glob, {timeout})
    F->>B: Read current URL
    
    loop Poll until timeout or match
        B-->>F: URL string
        F->>F: Match against Playwright glob semantics
        alt URL matches
            alt waitUntil specified
                F->>P: waitForLoadState(waitUntil, remainingTimeout)
            else default load
                F->>P: waitForLoadState("load", remainingTimeout)
            end
            P-->>F: Load complete
            F-->>T: Resolve
        else URL no match
            F->>B: Continue polling
        end
    end

    Note over F,T: Timeout=0 disables deadline (waits indefinitely)

    alt Callback evaluation
        T->>F: locator.evaluate(fn)
        F->>L: Serialize function
        L->>B: Execute in page context
        B-->>L: Result
        L-->>F: Return value
        F-->>T: Result
    end

    Note over B,PW: Contract comparison tests
    T->>T: Run test suite
    alt Integration tests
        T->>B: Launch local Chrome
        T->>PW: Native Playwright queries
        T->>F: Facade queries (same fixture)
        B-->>T: Results comparison
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/package.json
Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/integration/facade-dom.test.ts Outdated
Comment thread packages/integrations/core/integration/facade-dom.test.ts
}
}),
).filter((element) =>
roots.some((root) => root instanceof Document || root.contains(element)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think root.contains(element) will cross any shadow boundaries (open or closed)

* resolveStagehandShadowHopMatches: child steps walk light-DOM children,
* a `//` step after the first walks into the host's (open) shadow root.
*/
const resolveStagehandXPath = (expression: string): Element[] => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update to support closed shadow roots in the facade too?

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