python-3.x - 如何使用带有 Appium 和 Python 的 Android 键盘键入文本?
问题描述
介绍
我正在使用 Appium 在 Python 3.7 中开发一个脚本。它将在真正的 Android 智能手机上自动执行一些任务。我的脚本需要在文本字段中输入一些文本。我不想使用 send_keys 方法或 ActionChains。我更喜欢使用智能手机的键盘逐个字符地键入文本。
问题
我调查并阅读了各种文档:
按键代码
https://appium.readthedocs.io/en/latest/en/commands/device/keys/press-keycode/
这把我带到了 Keyevent
https://developer.android.com/reference/android/view/KeyEvent.html
这让我想到了 KeyCharacterMap
https://developer.android.com/reference/android/view/KeyCharacterMap.html
老实说,在我读完这一切之后,我很难理解这一切。
所以我做了一些实验,尝试不同的代码行来看看会发生什么:
driver.press_keycode(0)
driver.press_keycode(1)
driver.press_keycode(2)
ETC...
似乎什么都没有发生。
有没有人知道一个好的教程或文章可以解释我如何使用键盘而不是 send_keys 方法和 ActionChains 在 Android 智能手机应用程序的文本字段中键入文本?
你能帮我找到路吗?
解决方案
推荐阅读
- asp.net-core - Asp.net Core 如何为 PackageReference 指定 TargetFramework?
- reactjs - 如何使用 reactjs 将一个组件两次用于另一个选项卡?
- python-3.x - 无法使基本的 Celery 示例正常工作(无法连接到 amqp://guest:**@127.0.0.1:5672//)
- wordpress - WooCommerce 重复第一个产品图片
- amazon-web-services - Sails.js 应用程序无法连接到 AWS RDS 数据库中的 MySql 数据库,适用于 localhost(MySql)
- java - android studio 看不到模拟器
- azureservicebus - 我们可以根据 Azure Service Bus 中的消息内容查询消息吗?
- haskell - Servant.Swagger ToSchema for Data.Bson.ObjectId
- python - 在 NodeJS 上获取 Pyspark 作业输出
- python - 为什么 Python 会锁定端口?这可以安全地用于简单的概念验证实时应用吗