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

test: add shortcut for pressing multiple keys simultaneously #8536

Merged
merged 8 commits into from
Jan 29, 2025

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Jan 20, 2025

Description

Extends the default sendKeys implementation to support pressing multiple keys simultaneously in Puppeter and Playwright when provided in the format Shift+Tab. In screenshot tests, however, this functionality will still be unavailable because WebDriver's sendKeys implementation does not provide an API for holding keys down.

Depends on

Type of change

  • Internal

export * from '@web/test-runner-commands';

export async function sendKeys(options) {
Copy link
Contributor Author

@vursen vursen Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to use the same approach to extend the API of sendMouse to support

- const { x, y } = middleOfNode(button) 
- sendMouse({ type: 'click', position:  [Math.floor(x), Math.floor(y)] }); 
+ sendMouse({ type: 'click', element: button }); 

@vursen vursen force-pushed the test/add-shortcut-for-pressing-keys-with-modifiers branch from 0126cec to ff44b45 Compare January 20, 2025 11:30
@vursen vursen marked this pull request as ready for review January 20, 2025 13:23
@vursen vursen marked this pull request as draft January 20, 2025 15:19
@vursen vursen force-pushed the test/add-shortcut-for-pressing-keys-with-modifiers branch from 344a6d0 to f474ed6 Compare January 25, 2025 18:19
@vursen vursen marked this pull request as ready for review January 25, 2025 18:21
Base automatically changed from vaadin-test-runner-commands to main January 27, 2025 13:50
@vursen vursen force-pushed the test/add-shortcut-for-pressing-keys-with-modifiers branch from f474ed6 to a39763e Compare January 27, 2025 13:53
@vursen vursen changed the title test: add shortcut for sending keys with modifiers test: add shortcut for pressing multiple keys simultaneously Jan 27, 2025
@vursen vursen force-pushed the test/add-shortcut-for-pressing-keys-with-modifiers branch from 632b112 to 3a885ab Compare January 27, 2025 15:45
@vursen vursen requested a review from web-padawan January 28, 2025 07:42
Copy link
Member

@web-padawan web-padawan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One case reported above still seems not replaced:

await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });

@vursen
Copy link
Contributor Author

vursen commented Jan 28, 2025

One case reported above still seems not replaced:

Thanks, replaced.

@vursen vursen force-pushed the test/add-shortcut-for-pressing-keys-with-modifiers branch 2 times, most recently from 9d0781a to 7f6a178 Compare January 29, 2025 06:29
@vursen vursen force-pushed the test/add-shortcut-for-pressing-keys-with-modifiers branch from 7f6a178 to b7e2931 Compare January 29, 2025 08:35
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@web-padawan web-padawan merged commit c1518f7 into main Jan 29, 2025
8 of 9 checks passed
@web-padawan web-padawan deleted the test/add-shortcut-for-pressing-keys-with-modifiers branch January 29, 2025 09:06
@vaadin-bot
Copy link
Collaborator

Hi @vursen and @web-padawan, when i performed cherry-pick to this commit to 24.6, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick c1518f7
error: could not apply c1518f7... test: add shortcut for pressing multiple keys simultaneously (#8536)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

@vaadin-bot
Copy link
Collaborator

Hi @vursen and @web-padawan, when i performed cherry-pick to this commit to 24.5, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick c1518f7
error: could not apply c1518f7... test: add shortcut for pressing multiple keys simultaneously (#8536)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.7.0.alpha7 and is also targeting the upcoming stable 24.7.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants