Skip to content

feat(locator): add clickability checks and assertions - #43861

Closed
microsoft-playwright-automation[bot] wants to merge 1 commit into
mainfrom
triage/43849/41502168704-1
Closed

microsoft-playwright-automation[bot] wants to merge 1 commit into
mainfrom
triage/43849/41502168704-1

Conversation

@microsoft-playwright-automation

@microsoft-playwright-automation microsoft-playwright-automation Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Locator.isClickable(): runs the actionability checks of a click once (visible, stable, enabled, not inert, receives pointer events) without clicking and without a timeout.
  • expect(locator).toBeClickable(): the same check inside the regular expect loop, so every poll resolves the locator again and cycles the scroll alignments like click().
  • Both reuse the trial-click code path of click().

Fixes #43849

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread docs/src/api/class-locator.md Resolved
Comment thread docs/src/api/class-locator.md Resolved
Comment thread docs/src/api/class-locatorassertions.md Resolved
Comment thread docs/src/api/class-locator.md Resolved
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

Hi, I'm the Playwright bot and I addressed the seven review threads.

Removed timeout and signal options from isClickable(), including the generated types. The new documentation describes the checks directly, without trial-click references, and ends with the scrolling note. Restored the full scroll-alignment comment.

Both APIs now use the shared _click implementation. The assertion selects its evaluator once and uses the common retry and result-handling logic.

Build and flint passed. The changed and neighboring test files passed on Chromium, Firefox and WebKit: 772 passed, 2 skipped. The timeout check failed with the original client; all 12 feature checks failed without the implementation and passed after restoring it.

Revised on Linux by the Playwright bot - agent run

const resolved = await progress.race(this.selectors.callOnSelectorHandle({ ...target, markTargets: 'all' }, ({ elements }) => elements[0] as Element, {}));
if (!resolved)
return null;
const handle = resolved.result;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is conceptually wrong - you are retrying after resolution which is against Playwright principles. Look at how toBeVisible works probably - it is the closest to what you are trying to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The current code already re-resolves on every assertion retry, as toBeVisible() does: _click(..., retry) selects _performPointerAction, not _retryPointerAction. A three-browser check confirmed one query for isClickable() and a fresh query for toBeClickable() that checked a replacement target, so I made no code change.

Revised on Linux by the Playwright bot - agent run

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

@github-actions

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

Hi, I'm the Playwright bot. I checked the retry behavior and left the code unchanged.

For the review comment, _click(..., retry) makes one attempt through _performPointerAction, bypassing _retryPointerAction. Only the assertion loop retries, resolving the locator again each time.

A custom-selector check confirmed this on Chromium, Firefox and WebKit: isClickable() queried once; toBeClickable() queried twice and checked a replacement button. Build and flint passed; changed and neighboring tests had 805 passes and 2 skips. The 12 feature checks failed with the base source and passed after restoring the PR source.

Revised on Linux by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🟡 Likely unrelated, but one failure remains uncertain

Hi, I'm the Playwright bot. I checked the latest CI report for c46dd12d67fc.

Details

No failure clearly points to this PR. The hard failure happened during page setup, before the test body ran. The separate UI-mode test is a confirmed pre-existing flake.

Uncertain

  • [playwright-test] › test-step.spec.ts:1483 › reading network request / response should not be listed as step — Windows Server 2025, Node 22. The failed job log shows Test timeout of 3000ms exceeded while setting up "page". The nested test exited with code 1; it never reached the network operations or the step-output comparison. This PR changes clickability checks, pointer actions and locator assertions, not page creation, so runner timing looks more likely than a regression here.

    However, after refreshing the CI database, I found no failed attempts in 3,846 test runs outside this PR, including 512 on this same Windows bot. There is no independent evidence to call this a pre-existing flake. A repeat of the Windows test at this head, followed by a base-commit comparison if it still fails, would help resolve this.

Pre-existing flake

  • [playwright-test] › ui-mode-trace.spec.ts:741 › should be able to create and dispose APIRequestContext inside Promise.all — passed on retry here. The same test on the same Windows bot also failed and then passed on retry in unrelated devops(bots): publish the agent's GitHub writes as typed calls #43838 (November 1 run), with the identical status-line timeout: expected 1/1 (100%) — 1 passed, received 0/1 (0%).

Triaged by the Playwright bot - agent run

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [webkit] › mcp/http.spec.ts:92 › http transport browser lifecycle (isolated) @mcp-ubuntu-latest-webkit

5193 passed, 616 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🟢 Latest MCP failure is a pre-existing flake

Hi, I'm the Playwright bot. I checked the latest MCP report. Its single failure is unlikely to be caused by this PR.

Details

The failure matches one seen before this PR existed. There is no evidence of a regression from the clickability changes in this report.

Pre-existing flake

  • [webkit] › mcp/http.spec.ts:92 › http transport browser lifecycle (isolated) — timed out after 30 seconds on mcp-ubuntu-latest-webkit in the current job. The same test on the same bot had the identical timeout on October 28, on main at 4d05531e1483, before this PR opened on November 2 (failed job). It also timed out in unrelated Revert "fix(mcp): do not mark test tools that run code or write files as read-only" #43769 on October 29 (run).
  • After refreshing the CI database, this exact test and bot have 11 failing runs outside this PR; 738 of 750 total runs passed. The test opens and closes HTTP sessions and browser contexts. It does not use the click actions or locator assertions changed here; the PR does not change HTTP session or browser lifecycle code.

Triaged by the Playwright bot - agent run

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

Warning

The triggering workflow run ended with status cancelled. Results below may be incomplete — blob reports from cancelled or timed-out shards are missing, so passing/failing counts do not reflect the full test suite.

18575 passed, 531 skipped


Merge workflow run.

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.

[Feature]: Extend isVisible/toBeVisible API to include overlap detection

1 participant