adamdriscoll/selenium-powershell

Improve Invoke-SeKeyAction

itfranck opened this issue · 1 comments

Currently, doing a CTRL + S would be done in 3 statements.

Invoke-SeKeyAction -Element $Element -Action KeyDown -Key CTRL
Invoke-SeKeys -Element $Element -Keys 's'
Invoke-SeKeyAction -Element $Element -Action KeyUp -Key CTRL

Since this looks like a common scenario, it should be possible to do it in one sweep.

Removed Invoke-SeKeyAction.
Instead, Invoke-SeKeys, whenever it has modifier keys, will do Key down for all the modifier keys (in the order they were found but regardless of what is in-between) and a keyup at the end.

For instance

"{{Control}}a" will do

  • Key down Control
  • Send A
  • Key Up Control

But

"{{Control}}a{{Shift}}" will actually do :

  • Keydown Control
  • KeyDown Shift
  • Send A
  • Key up both modifier keys.

This keydown / keyup behavior will only be applied whenever the string to send start with a special key.