puppeteer: Cmd+A doesn't select all on Mac
There are two types of shortcuts: those handled by OS and those handled by Chrome
Alt-Tab
is an example of a native shortcutShift-Left
is an example of Chrome-handled shortcut
Puppeteer doesn’t emulate native shortcuts because native shortcuts depend on the active window, which is out of control for puppeteer.
Certain shortcuts, such as “select all”, are handled differently on different platforms:
- On Win and Linux,
Ctrl-A
is handled by Chrome, and puppeteer does emulate this - On OS X,
⌘-A
is handled by OS X, and puppeteer doesn’t emulate this
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (2 by maintainers)
Commits related to this issue
- Fix failing e2e testing due to additional of toolbar e2e tests were failing due to introduction of valign toolbar meaning that number of tab stops needed to be increased by 3 (the number of items in ... — committed to getdave/gutenberg by getdave 5 years ago
- Core Columns Block - adds ability to vertically align all the columns (#13899) * Adds ability to valign all the columns via parent Proof of concept demonstrating ability to change the valignment o... — committed to WordPress/gutenberg by getdave 5 years ago
- Do not paste text on macOS in e2e tests Pasting text was introduced in f2365a5f3e8b729663d83f1158d6d4ccabb28903 and doesn't work on my macOS machine. Reading through https://github.com/GoogleChrome/... — committed to sourcegraph/sourcegraph by mrnugget 5 years ago
- Do not paste text on macOS in e2e tests (#5044) Pasting text was introduced in f2365a5f3e8b729663d83f1158d6d4ccabb28903 and doesn't work on my macOS machine. Reading through https://github.com/Go... — committed to sourcegraph/sourcegraph by mrnugget 5 years ago
- DevTools: Add commands option to Input.dispatchKeyEvent Key events emulated with DevTools can now use the commands option to send editing commands that will be executed if the event is not canceled. ... — committed to blueboxd/chromium-legacy by JoelEinbinder 4 years ago
- Add mac support https://github.com/puppeteer/puppeteer/issues/1313 appears to have been sufficiently addressed to support mac command/meta key — committed to nickzylstra/the_room by deleted user 2 years ago
- DevTools: Add commands option to Input.dispatchKeyEvent Key events emulated with DevTools can now use the commands option to send editing commands that will be executed if the event is not canceled. ... — committed to mjfroman/moz-libwebrtc-third-party by JoelEinbinder 4 years ago
- feat(keyboard): keydown supports commands Issue: #1313 — committed to Junyan/puppeteer by Junyan 2 years ago
- feat(keyboard): keydown supports commands Issue: #1313 — committed to Junyan/puppeteer by Junyan 2 years ago
- feat(keyboard): keydown supports commands Issue: #1313 — committed to Junyan/puppeteer by Junyan 2 years ago
- feat(keyboard): keydown supports commands Issue: #1313 — committed to Junyan/puppeteer by Junyan 2 years ago
- feat(puppeteer-core): keydown supports commands (#9357) Issue: #1313 <!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. --> ... — committed to puppeteer/puppeteer by Junyan 2 years ago
You can solve your problem by clicking 3 times in a row and then deleting your text.
await input.click({ clickCount: 3 }); await page.keyboard.press("Backspace");
This is still a problem in my testing. I’d think the issue should be reopened.
In the meantime, what’s worked for me as a viable alternative for “select all” is:
I’m also having an issue with simulating command click:
It doesn’t open a new tab.
Expanding on my previous comment, it ultimately wasn’t quite enough for our application which included more advanced handling to
preventDefault
the Cmd+A behavior under some conditions.The full implementation ended up being just a bit more complex:
I get it that you can’t hijack Alt on Linux/Windows machines but you CAN do this on a Mac (it’s the Option key on a mac).
Likewise, on a Mac you can easily create browser behavior that uses the Option key, javascript that recognizes when the Option key is pressed, etc.
I feel like it would make more sense to have this be platform-dependent, right now the implemention on Mac is limited by windows/Linux compatibility issues that shouldn’t affect it.
Even in the name of this bug it says “on the mac” so I’m not sure why it’s closed, the problems cited for reasons for closing this bug aren’t really relevant to the Mac.
Command + v
is not working on mac also, but i find a solution, https://stackoverflow.com/questions/11750447/performing-a-copy-and-paste-with-selenium-2#answer-41046276 . in my mac, i confirmed that it works.I’m also having an issue with simulating a paste from clipboard. tried
This works for me, just change params from clickCount to count