feat(keyboard): add array overload to pressSequentially#40748
Open
SebTardif wants to merge 3 commits into
Open
feat(keyboard): add array overload to pressSequentially#40748SebTardif wants to merge 3 commits into
SebTardif wants to merge 3 commits into
Conversation
pavelfeldman
approved these changes
May 9, 2026
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dgozman
reviewed
May 11, 2026
| ### option: Frame.press.timeout = %%-input-timeout-js-%% | ||
| * since: v1.8 | ||
|
|
||
| ## async method: Frame.pressSequentially |
Collaborator
There was a problem hiding this comment.
Let's not introduce a discouraged method 😄
| - `text` <[string]|[Array]<[string]>> | ||
|
|
||
| String of characters to sequentially press into a focused element. | ||
| String of characters to sequentially press into a focused element, or an array of key names to press sequentially. Key names follow the same format as [`method: Locator.press`]. |
Collaborator
There was a problem hiding this comment.
How about we support the following notation: Hello{ArrowRight}{Ctrl+A}world!{Backspace}? Basically, treating anything inside {} as a key from the press method, when passed a namedKeys: true option.
Contributor
Author
There was a problem hiding this comment.
Reworked. Added namedKeys: true option to Locator.pressSequentially and Keyboard.type. {KeyName} treats brace content as a key name for press(), with {{/}} for literal braces.
await locator.pressSequentially('Hello{Enter}World', { namedKeys: true });
await locator.pressSequentially('{Control+A}{Delete}Hello', { namedKeys: true });
await locator.pressSequentially('type {{braces}}', { namedKeys: true }); // types: type {braces}Add string[] overload to Locator.pressSequentially and new Keyboard.pressSequentially method, as requested in microsoft#40740. When given an array, each element is treated as a key name (same format as keyboard.press()) and pressed sequentially with optional delay between presses. Fixes microsoft#40740
Add missing documentation for Frame.pressSequentially selector-based method to fix doclint CI failure. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Rework pressSequentially based on review feedback:
- Drop Frame.pressSequentially (no new discouraged methods)
- Drop Keyboard.pressSequentially and keyboardPressSequentially protocol
- Add namedKeys option to Locator.pressSequentially and Keyboard.type
- {KeyName} syntax treats braces content as key names for press()
- {{ and }} escape to literal brace characters
Fixes: microsoft#40740
aec15c9 to
4375b42
Compare
Contributor
Test results for "MCP"1 failed 7069 passed, 1068 skipped Merge workflow run. |
Contributor
Test results for "tests 1"2 flaky40747 passed, 845 skipped Merge workflow run. |
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.
Summary
string[]overload toLocator.pressSequentiallyso it can accept an array of key names in addition to a string of charactersKeyboard.pressSequentiallymethod mirroring the same behaviorkeyboard.press()) and pressed sequentially with optional delay between pressesUsage:
Fixes #40740