如何使用 Python 操作Send_keys发送"special characters"?



我正在用Python 3.7编写代码,用于在Appium中测试应用程序。

我正在尝试在应用程序的输入字段中发送文本。文本为法语,带有特殊字符(é、è、à 等)。

我的代码设法逐个字符逐个键入,但是当它到达带有重音"é"的特殊字符时,它就出错了!这是错误消息:

Encountered internal error running command: io.appium.uiautomator2.common.exceptions.InvalidArgumentException: KeyCharacterMap.getEvents is unable to synthesize KeyEvent sequence out of '233' key code. Consider applying a patch to UiAutomator2 server code or try to synthesize the necessary key event(s) for it manually

我阅读了文档和论坛,并添加了此功能:

desired_caps['unicodeKeyboard'] ='true'

但这并没有改变任何东西。我仍然有同样的问题。

尝试发送如下密钥:

self.driver.find_element().send_keys(u'éèà')

true更改为True desired_caps['unicodeKeyboard'] ='True'

这可能会对你有所帮助

http://appium.io/docs/en/writing-running-appium/other/unicode/

最新更新