Skip to content

Conversation

PotatoCP
Copy link
Contributor

@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
Contributor 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.

@madsmtm
Copy link
Member

madsmtm commented Oct 2, 2025

Returning back to this:

I'm actually somewhat inclined to remove the webdriver module in v0.9.x, and instead split it into a different crate, to allow it to evolve at a different pace than the main keyboard-types crate, which otherwise contains (mostly) types that the entire ecosystem depends on for interop with other crates.

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