docs: use locator-first examples in the API reference - #53
Open
luantaraschi wants to merge 1 commit into
Open
Conversation
The reference showed six page-level selector APIs that Playwright marks discouraged (page.click, page.fill, page.selectOption, page.setInputFiles, page.hover, page.dblclick) and one that is outright deprecated (locator.type). A skill's reference is what an agent copies, so each example now uses the form the current docs prefer. locator.type carries a deprecation note pointing at locator.fill, with locator.pressSequentially for pages that need per-key events; the example now shows both and says which is which. page.keyboard.type is left alone: it carries no such note, and the Keyboard class docs still describe it as the high-level api and use it in their own example. Closes lackeyjb#46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #46.
I checked every candidate against Playwright's own doc source (
microsoft/playwright,docs/src/api/*.md) rather than going from memory, since the issue asks to replace only where current guidance clearly prefers something better. Three groups came out of it.Deprecated, replaced.
locator.typecarries a deprecation note verbatim:The "clear and type" example now shows
fillfor the ordinary case andpressSequentiallyfor the per-key one, labelled so a reader knows which situation each is for, rather than silently swapping one for the other.Discouraged, replaced. Six page-level selector APIs in the reference carry a
discouragedmarker pointing at their locator equivalent:class-page.mdpage.clickLocator.clickinsteadpage.fillLocator.fillinsteadpage.selectOptionLocator.selectOptioninsteadpage.setInputFilesLocator.setInputFilesinsteadpage.hoverLocator.hoverinsteadpage.dblclickLocator.dblclickinsteadThose cover the form, mouse, network-wait, data-driven, popup and download examples. Where the element was described by role in prose I used
getByRolerather than mechanically wrapping the CSS selector inpage.locator(...), since the reference already teaches role-first locators a few sections earlier; where the example was pinned to a specific id or class I kept that selector and just moved it into a locator.Not touched, on purpose.
page.keyboard.typestays. It has no deprecation or discouraged note, andclass-keyboard.mdstill calls it "the high level api" and uses it in its own example. Replacing it would have been the audit overreaching. I also found nowaitForTimeoutand nonetworkidleanywhere in the file, so nothing to do on the two patterns the issue names first.What I ran, on Windows with Node 22.20.0:
npm testinskills/playwright-skill: 12 pass, 0 failnpx skills-ref@0.1.5 validate .in the same directory, which is what CI runs:Valid skill: .Docs-only change, 22 lines added and 19 removed, no behaviour anywhere.