2gis / Winium.StoreApps.CodedUi

Prototype of Winium.StoreApps driver using CodedUI. Implements JsonWireProtocol for automation of Windows Phone applications
10 stars 8 forks source link

Add support for control keys in SendKeys #8

Closed NickAb closed 6 years ago

NickAb commented 9 years ago

Currently SendKeys is not able to send control keys (like Enter) to the element.

This is due to use of ValuePattern.SetValue(value) instead of full keyboard simulation. We should provide some way to be able to send control keys at least at the end of input, e.g. "Some text" + Keys.ENTER should work.

NickAb commented 9 years ago

:+1: I'll take a look on how to include it in SendKeys method later.

I think for first draft SendKeys would use following algorithm:

  1. Separate input value into regular keys and special keys (Enter, Backspace, etc.)
  2. Set focus to the element
  3. Use SetValue for regular keys
  4. Use click simulation on on-screen keyboard elements for special keys

So this implementation will be not fully complaint to JSONWireProtocol, as we would be able to enter special keys only after the rest of the input string. Full compliance will require further research on how to map string characters to sequence of on-screen keyboard presses.

truptibhatt commented 6 years ago

@NickAb - Can you tell me how you have achieved this functionality? I need to send the shift tab key but not able to achieve it. Can you do needful. Thanks in advance I am using winium and Java

NickAb commented 6 years ago

@truptibhatt, I am not sure what Shift-Tab stands for on Windows Mobile platform. Could you explain?

Please note that we did not implement this feature in CodedUI version of the driver. This was a proof of concept to see if we should switch to CodedUI from our embeddable driver. This project is not maintained any more.

The best I can do is suggest some direction or workaround at the moment.

truptibhatt commented 6 years ago

@NickAb - thanks for the quick response. i guess it is wrong thread i have started over here. i am new to Winium.Desktop.Driver . I have implemented it very first time. Actually in one of the window. i want to press shift +tab to go get focus on particular tree node. I did couple of tries ,but no luck. for eg: WebElement player = driver.findElement(locator1); player.sendKeys(Keys.ENTER);

I am not sure it is supported by winium desktop driver or not. I have couple of queries for winium desktop driver 1) need to use sendkeys with tab or enter key 2) drag and drop functionality 3) click on tree node to select the particular node from tree

NickAb commented 6 years ago

For Shift+Tab I would try using action chain. It might look something like this

actions.click(element).keyDown(Keys.Shift).keyDown(Keys.ENTER).keyUp(Keys.ENTER).keyUp(Keys.Shift).perform();

or

actions.click(element).keyDown(Keys.Shift).sendKeys(Keys.ENTER).keyUp(Keys.Shift).Perform();

Not sure if sendKeys is supported in chain, but there is a test for keyDown, keyUp chain.

Same for drag and drop, it might work with action chains, but it is better to ask at 2gis/Winium.Desktop page.