Skip to content

feat: add ElementHandle.AsLocator() (upstream alignment)#3383

Merged
kblok merged 2 commits intomasterfrom
feat/element-handle-as-locator
Mar 11, 2026
Merged

feat: add ElementHandle.AsLocator() (upstream alignment)#3383
kblok merged 2 commits intomasterfrom
feat/element-handle-as-locator

Conversation

@kblok
Copy link
Copy Markdown
Member

@kblok kblok commented Mar 11, 2026

Summary

  • Add AsLocator() method to IElementHandle interface and ElementHandle abstract class, matching upstream Puppeteer's asLocator() API
  • Introduce internal HandleLocator class in PuppeteerSharp.Locators that wraps an existing IElementHandle directly, returning it from WaitHandleCoreAsync without querying the DOM
  • Allows converting any element handle into a locator for use with locator-based action APIs (click, fill, hover, etc.)

Test plan

  • dotnet build PuppeteerSharp/PuppeteerSharp.csproj succeeds with 0 warnings, 0 errors
  • dotnet build PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj compiles successfully (only pre-existing dev cert error in TestServer)
  • CI validates no regressions in existing tests

🤖 Generated with Claude Code

kblok and others added 2 commits March 11, 2026 09:28
Add AsLocator() method to IElementHandle and ElementHandle that converts
an existing ElementHandle into a Locator, matching upstream Puppeteer's
asLocator() API. Introduces HandleLocator, an internal locator that wraps
an element handle directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant