Skip to content

Element SendKeys supports strings for different locales and non-US keaybords#137

Closed
PiotrNestor wants to merge 2 commits intoFlaUI:mainfrom
system-verification:non-us-keyboards
Closed

Element SendKeys supports strings for different locales and non-US keaybords#137
PiotrNestor wants to merge 2 commits intoFlaUI:mainfrom
system-verification:non-us-keyboards

Conversation

@PiotrNestor
Copy link

@PiotrNestor PiotrNestor commented Mar 19, 2025

@jensakejohansson
@hugoMeier
@aristotelos
@Roemer
@stevemonaco
@bmarroquin

The issue solves the issue as reported here:
#129

The updated implementation: Uses Flaui.Core.Input Keyboard.Type to handle the ElementSendKeys request.
The FlaUI.Core already handles many more characters in strings than the WebDriver does not.

It is possible that ElementSendKeys should handle many more string variants containing for example Selenium Keys.XXX but

  • this is not handled in the original WebDriver implementation
  • it is handled by WebDriver PerformActions anyways

Added also some UITests that confirm the updated functionality.

In general it's unclear what Selenium actions are supposed to work in SendKeys

In other words:
In the original implementation this does not work - select the first word in a input element and delete it:

element.SendKeys(Keys.Home);
element.SendKeys(Keys.Shift + Keys.Control + Keys.ArrowRight);
element.SendKeys(Keys.Delete);

this works in stead

Actions actions = new Actions(_driver);
            actions
                .Click(element)             
                .SendKeys(Keys.Home)
                .KeyDown(Keys.Shift)      
                .KeyDown(Keys.Control)
                .SendKeys(Keys.ArrowRight)
                .KeyUp(Keys.Control)
                .KeyUp(Keys.Shift)
                .SendKeys(Keys.Delete)
                .Perform(); 

Obviously the above is the same in this PR

@PiotrNestor
Copy link
Author

@aristotelos
Any input on this PR?
Can we trade this extended support for many different characters and keyboards in stead of the unclear support for Selenium actions via SendKeys?

@PiotrNestor
Copy link
Author

@aristotelos
@jensakejohansson

Added now also support for SendKeys with embedded actions and composite actions
The implementation uses FlaUI.Core.Input Keyboard to dispatch the keys

Added also some UITests with KendKeys embedded actions examples.
More examples are possible.

{
await _actionsDispatcher.DispatchActionsForString(session, inputId, source, elementSendKeysRequest.Text);
//await _actionsDispatcher.DispatchActionsForStringUsingFlaUICore(session, inputId, source, elementSendKeysRequest.Text);
await _actionsDispatcher.DispatchSendKeysUsingFlaUICore(elementSendKeysRequest.Text);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really like having two branches of code for dispatching actions... Can't we replace the DispatchActionsForString implementation?

@aristotelos
Copy link
Collaborator

aristotelos commented Apr 4, 2025

There seems to be a conflict here between:

  • Following the standard to the letter
  • Supporting different keyboard lay-outs

If that is the case, I would first like to have this raised for the WebDriver standard. @PiotrNestor have you tried that?

If that attempt has been done and has proved unsuccessfully, we could make a conscious choice to deviate from it and document that very explicitly.

@aristotelos
Copy link
Collaborator

Closing the PR because the unanswered questions have to be resolved first

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants