feat(playwright): human.clear() — humanized field clearing + human_clear MCP tool#48
Merged
Conversation
Clears a text field with a real humanized gesture — click to focus, select-all (platform-aware Mod+A), a beat, then Delete — firing the input events the page expects. Pairs with type() to replace an existing value. Instant mode delegates to Playwright's native locator.clear(). Mirrored as the human_clear MCP tool, exported by the recorder codegen, documented in the skill primitives table, and backed by a new 'clear' KnownActionType in @humanjs/core. Colocated tests cover the humanized gesture and the instant path.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What & why
Step 2 of the form-interaction work. Real flows don't just fill empty fields — they edit existing values (settings pages, "change your email", correcting a typo'd form). Until now you'd have to drop to raw Playwright (
locator.clear()/fill('')) for that.human.clear()closes it.Behavior
A real keyboard gesture, not a silent value reset:
type/paste)Mod+A(Meta+Aon macOS,Control+Aelsewhere), via the same resolverhuman.pressusesFires the
keydown/up+inputevents the page expects (validation, "dirty" state, etc.). Works for inputs, textareas, and contenteditable.In
speed: 'instant', delegates to Playwright's nativelocator.clear()— no visible gesture, consistent with the rest of instant mode.Surface (full parity)
@humanjs/playwright:human.clear(target)(executor in the keyboard module, besidetype/paste).@humanjs/mcp:human_cleartool.toPlaywright/toHumanJS.@humanjs/core: new'clear'KnownActionType.Tests
Colocated tests cover the humanized gesture (focus click → select-all chord → Delete, no native clear) and the instant path (native
locator.clear(), no gesture/motion). Gate green: lint · typecheck 9/9 · tests 8/8 · check:exports (publint) 11/11.Changeset
minorfor@humanjs/playwright+@humanjs/mcp+@humanjs/core,patchfor@humanjs/skill.