Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendKeys Key combinations (incl cross-platform) #13

Closed
lachie opened this issue Oct 2, 2018 · 4 comments
Closed

sendKeys Key combinations (incl cross-platform) #13

lachie opened this issue Oct 2, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@lachie
Copy link
Contributor

lachie commented Oct 2, 2018

I'd like to be able to do key combos using browser.sendKeys() and the Key enum to simulate typing on a keyboard.
Additionally I need to send different key combinations depending on the platform the test script will run on.

Command-Key combos might not be possible on mac, but there are still plenty of web-apps which handle keyboard input directly for key combos.
puppeteer/puppeteer#1313

When developing the test script using Element on my Mac I'd copy something with CMD-C, but when the script runs on flood.io it'll be running under linux, where the equivalent combo is CTRL-C. This point may be moot depending on puppeteer#1313

A simple API would be to allow grouping sendKeys inputs into arrays: browser.sendKeys( [Key.CONTROL, "A"] ) would press CTRL-A

Not all keys listed are included in the Key enum

@lachie lachie mentioned this issue Oct 2, 2018
47 tasks
@jrizio
Copy link
Contributor

jrizio commented Nov 30, 2018

A customer has requested for this very same functionality. Puppeteer has an interesting approach as follows:

page.keyboard.down('Shift', {delay: 250}); page.press('ArrowLeft', {delay: 250}); page.keyboard.up('Shift', {delay: 250});

It also appears that the above keyboard functionality is the preferred method in Puppeteer for doing key combinations with the added accuracy of using delay times too (if needed).

@ivanvanderbyl ivanvanderbyl added the enhancement New feature or request label Jan 16, 2019
@ivanvanderbyl ivanvanderbyl added this to the v1.1 milestone Jun 7, 2019
@ivanvanderbyl ivanvanderbyl added this to To do in Roadmap via automation Jun 7, 2019
@ivanvanderbyl
Copy link
Contributor

I think we can adopt something similar to this, just like we did with the browser.mouse PR.

@ivanvanderbyl ivanvanderbyl self-assigned this Jun 20, 2019
@jrizio
Copy link
Contributor

jrizio commented Jun 20, 2019

We have access to the page object as of 1.0.5 so we'll be able to use this functionality based on Lachie's improvements.

@ivanvanderbyl ivanvanderbyl modified the milestones: v1.1, v1.2, v1.3 Apr 2, 2020
@ivanvanderbyl
Copy link
Contributor

ivanvanderbyl commented Apr 21, 2020

browser.keyboard.pressCombination("Ctrl+A")

===

page.keyboard.down('Ctrl')
page.keyboard.press('A')
page.keyboard.up('Ctrl')

@phileba phileba self-assigned this Apr 21, 2020
@phileba phileba moved this from To do to In progress in Roadmap Apr 21, 2020
@phileba phileba moved this from In progress to Review in progress in Roadmap Apr 23, 2020
@phileba phileba moved this from Review in progress to Shipped in Roadmap May 12, 2020
@phileba phileba closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Roadmap
  
Shipped
Development

No branches or pull requests

4 participants