Skip to content

Create KeyItem struct for send_keys #79

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PotatoCP
Copy link

@PotatoCP PotatoCP commented Jun 4, 2025

Modify behaviour of send_keys:

  • Separates dispatch_typable and clear function from KeyInputState
  • Return KeyItem instead of KeyboardEvent so we get can raw char and can convert it to action objects for dispatch actions.

Note that on spec, we should not immediately dispatch the event. Rather we should went through dispatch action steps.

Fixes #78.

@PotatoCP PotatoCP marked this pull request as draft June 4, 2025 02:32
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
@PotatoCP PotatoCP marked this pull request as ready for review June 4, 2025 03:15
Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

  • Separates dispatch_typable and clear function from KeyInputState
  • Return KeyItem instead of KeyboardEvent so we get can raw char and can convert it to action objects for dispatch actions.

It would make it easier for me to review this if you could split it into two PRs?

Also, could you add a test that breaks with the old behaviour, but works with the new? That'd make it easier for me to understand the change.

Comment on lines -410 to +393
Keyboard(KeyboardEvent),
Keyboard(KeyItem),
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'd like to avoid this breaking change. Why can you not use the character in KeyboardEvent::key's Key::Character(...) variant?

Copy link
Author

Choose a reason for hiding this comment

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

My concern is that we can't get the raw character for Key::Named. Much smaller changes is maybe to simply add raw_char on the KeyboardEvent. Do you think we should do that instead?

This change does not exactly fix behaviour for this crate, but it makes it simpler for user like web engine to implement Webdriver Element Send Keys command based on spec.

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

Successfully merging this pull request may close these issues.

Webdriver send keys should not return keyboard event
2 participants