WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

press_keycode endpoint not found (404)

Open dortonway opened this issue 7 years ago • 3 comments

I make self.driver.press_keycode(32) request from appium python client to Windows Server 2016 with WinAppDriver. It raises:

selenium.common.exceptions.WebDriverException: Message: Command not recognized: POST: /session/0EE8D504-0E79-418E-AA9F-5D079657AD12/appium/device/press_keycode

WinAppDriver shows:

==========================================
POST /session/0EE8D504-0E79-418E-AA9F-5D079657AD12/appium/device/press_keycode HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: keep-alive
Content-Length: 68
Content-Type: application/json;charset=UTF-8
Host: 116.202.1.50:4723
User-Agent: appium/python 0.46 (selenium/3.141.0 (python linux))

{"keycode": 32, "sessionId": "0EE8D504-0E79-418E-AA9F-5D079657AD12"}
### WinAppDriver::CommandHandler::Appium::HandleCommandAsMidPoint - Command  is not recognized
HTTP/1.1 404 Not Found
Content-Length: 164
Content-Type: application/json

{"status":9,"value":{"error":"unknown command","message":"Command not recognized: POST: /session/0EE8D504-0E79-418E-AA9F-5D079657AD12/appium/device/press_keycode"}}

According to docs endpoint seems to be correct: http://appium.io/docs/en/commands/device/keys/press-keycode/index.html

So how to press Space?

dortonway avatar Jul 05 '19 13:07 dortonway

Hi. You question is connected to this:
https://github.com/Microsoft/WinAppDriver/issues/464

As hassanuz wrote: "driver.keyevent (appium/device/keyvent) isn't an API supported by WinAppDriver - we recommend using send_keys (/session/:sessionId/element/elementID/value) as you have been for this. In addition, you can pass in keys.Enter."

riccione avatar Jul 07 '19 01:07 riccione

@riccione how can I send space button, not text?

I try: self.driver.find_element_by_name("Главное меню").send_keys(32)

Get in winappdriver:

==========================================
POST /session/62EE8242-70E1-4A38-B190-D27541F801D1/element/42.2557720.2.151595176.0/value HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: keep-alive
Content-Length: 122
Content-Type: application/json;charset=UTF-8
Host: 116.202.1.50:4723
User-Agent: appium/python 0.46 (selenium/3.141.0 (python linux))

{"text": "32", "value": ["3", "2"], "id": "42.2557720.2.151595176.0", "sessionId": "62EE8242-70E1-4A38-B190-D27541F801D1"}
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json

{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}


==========================================
DELETE /session/62EE8242-70E1-4A38-B190-D27541F801D1 HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: keep-alive
Content-Type: application/json;charset=UTF-8
Host: 116.202.1.50:4723
User-Agent: appium/python 0.46 (selenium/3.141.0 (python linux))


HTTP/1.1 200 OK
Content-Length: 12
Content-Type: application/json

{"status":0}

In appium python:

======================================================================
ERROR: test_addition (__main__.SimpleCalculatorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "calculatortest.py", line 73, in test_addition
    self.driver.find_element_by_name("Главное меню").send_keys(32)
  File "/home/i/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys
    'value': keys_to_typing(value)})
  File "/home/i/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/home/i/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/i/.pyenv/versions/3.6.5/lib/python3.6/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response
    raise wde
  File "/home/i/.pyenv/versions/3.6.5/lib/python3.6/site-packages/appium/webdriver/errorhandler.py", line 24, in check_response
    super(MobileErrorHandler, self).check_response(response)
  File "/home/i/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown error occurred in the remote end while processing the command.


----------------------------------------------------------------------
Ran 2 tests in 4.224s

dortonway avatar Jul 09 '19 18:07 dortonway

@dortonway, keys.Space would work (tested on C# though).

I think you can try using the special characters mentioned in the Selenium Python bindings: SPACE = u'\ue00d'¶.

Pleas keep in mind that support for keyboards outside of the NA standard is very limited, so SendKeys may not work as intended.

hassanuz avatar Jul 16 '19 01:07 hassanuz