WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Unable to send non-text keys to element

Open bharathp666 opened this issue 7 years ago • 5 comments

I'm unable to send non-text keys to element. I'm trying to send PAGE_UP = '\ue00e' to the element however no activity is seen in the application. Sending character a or \u0061 works without issues.

POST /session/85575879-112B-47BE-9A25-ADA96A3299D6/element/42.3999908.4.5/value HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 116
Content-Type: application/json
Host: localhost:4723
Postman-Token: 360f5ab0-1543-4851-9270-c229c258bc5c
User-Agent: PostmanRuntime/7.6.0

{"text": "\ue00e", "value": ["\ue00e"], "id": "42.3999908.4.5", "sessionId": "85575879-112B-47BE-9A25-ADA96A3299D6"}
HTTP/1.1 200 OK
Content-Length: 63
Content-Type: application/json

{"sessionId":"85575879-112B-47BE-9A25-ADA96A3299D6","status":0}
POST /session/85575879-112B-47BE-9A25-ADA96A3299D6/element/42.3999908.4.5/value HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 116
Content-Type: application/json
Host: localhost:4723
Postman-Token: 02eb2a21-cbcf-43a0-b60e-cb07b1985d5d
User-Agent: PostmanRuntime/7.6.0

{"text": "\ue061", "value": ["\u0061"], "id": "42.3999908.4.5", "sessionId": "85575879-112B-47BE-9A25-ADA96A3299D6"}
HTTP/1.1 200 OK
Content-Length: 63
Content-Type: application/json

{"sessionId":"85575879-112B-47BE-9A25-ADA96A3299D6","status":0}

WinAppdriver 1.1, Appium 1.9.1, Python 3.7.0, Windows 10

bharathp666 avatar Feb 07 '19 19:02 bharathp666

Hi @bharathp666,

As long as the focus is set on the right element, sending a Page Down or Page Up keyboard commands should work without any issue. Below is a snippet of working sample that opens Microsoft Edge and scrolls the page down and then up.

// Open about:flags page in Microsoft Edge using appArguments
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge");
appCapabilities.SetCapability("appArguments", "-private " + "about:flags");
session = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
Thread.Sleep(TimeSpan.FromSeconds(3));

session.Keyboard.SendKeys(Keys.PageDown);
Thread.Sleep(TimeSpan.FromSeconds(3));

session.Keyboard.SendKeys(Keys.PageUp);
Thread.Sleep(TimeSpan.FromSeconds(1));

timotiusmargo avatar Feb 13 '19 09:02 timotiusmargo

Hi @timotiusmargo, This doesnt work in python + Appium for a UWP Application. And even if the element is currently selected and in focus.

from selenium.webdriver.common.keys import Keys
self.driver.find_element_by_xpath(element).send_keys(Keys.PAGE_UP)

bharathp666 avatar Feb 15 '19 16:02 bharathp666

Hi @bharathp666,

This is interesting. You seem to be sending the right U+E00E character for the PageUp correctly according to the log. What event do you expect when you press the PageUp key manually on that particular instance? Have you checked if the event is propagated/handled correctly in the application?

timotiusmargo avatar Feb 27 '19 23:02 timotiusmargo

Not just PageUp or PageDown, even directional keys dont seem to work. But all keys works directly in the Application

bprabhus avatar Mar 13 '19 18:03 bprabhus

Hi @bharathp666,

As long as the focus is set on the right element, sending a Page Down or Page Up keyboard commands should work without any issue. Below is a snippet of working sample that opens Microsoft Edge and scrolls the page down and then up.

// Open about:flags page in Microsoft Edge using appArguments
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge");
appCapabilities.SetCapability("appArguments", "-private " + "about:flags");
session = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
Thread.Sleep(TimeSpan.FromSeconds(3));

session.Keyboard.SendKeys(Keys.PageDown);
Thread.Sleep(TimeSpan.FromSeconds(3));

session.Keyboard.SendKeys(Keys.PageUp);
Thread.Sleep(TimeSpan.FromSeconds(1));

Hi @timotiusmargo
This snippet, the rows: session.Keyboard.SendKeys(Keys.PageUp); and session.Keyboard.SendKeys(Keys.PageDown); shows up as obsolete code.

I wish to do the same in another test automation. Do you have a new snippet?

WinAppTester avatar Feb 05 '20 11:02 WinAppTester