Align label, strict locator, and URL wait semantics - #2895
Conversation
|
…olidation-05-locator-wait-contract
There was a problem hiding this comment.
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
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…olidation-05-locator-wait-contract
…olidation-05-locator-wait-contract
…olidation-05-locator-wait-contract
…olidation-05-locator-wait-contract
| } | ||
| }), | ||
| ).filter((element) => | ||
| roots.some((root) => root instanceof Document || root.contains(element)), |
There was a problem hiding this comment.
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[] => { |
There was a problem hiding this comment.
can we update to support closed shadow roots in the facade too?
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:
packages/integrations/core/src/facade/runtime.tspackages/integrations/core/integration/facade-dom.test.tspackages/integrations/core/tests/facade-wait-for-url.test.tsReadiness: 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.