uiautomator2 多种方式键盘输入

最近做了一个爬虫项目,在向文本框输入的时候,使用了多种方法(包含:send_keys、set_text)等多种方法都无效,最终选择了以下方案得到完美解决。

python 复制代码
# 切换输入法
d.set_fastinput_ime(True)
op_user_modify = d(className="android.view.View", index=2).send_keys("小迷糊")
d.set_fastinput_ime(False) #输入法用完记得关掉
python 复制代码
d.set_fastinput_ime(True)
d.clear_text()
d.send_keys("测试", True)
print("输入文本:     " + "测试")
d.set_fastinput_ime(False)  # 切换成正常的输入法
相关推荐
拓端研究室TRL12 分钟前
Python+AI提示词糖尿病预测融合模型:伯努利朴素贝叶斯、逻辑回归、决策树、随机森林、支持向量机SVM应用
人工智能·python·决策树·随机森林·逻辑回归
winfredzhang16 分钟前
使用Python和Selenium打造一个全网页截图工具
开发语言·python·selenium
mahuifa24 分钟前
(10)python开发经验
开发语言·python
Johny_Zhao1 小时前
AI+自动化测试系统方案:网络设备与网络应用智能测试
linux·网络·人工智能·python·网络安全·docker·ai·信息安全·云计算·ansible·shell·cisco·huawei·系统运维·itsm·华三·deepseek
科雷软件测试1 小时前
Python的re模块:正则表达式处理的魔法棒
python
照物华1 小时前
python中http.cookiejar和http.cookie的区别
爬虫·python·http
Dxy12393102162 小时前
Python 装饰器详解
开发语言·python
ganjiee00072 小时前
新电脑软件配置二:安装python,git, pycharm
python
Ronin-Lotus2 小时前
程序代码篇---python向http界面发送数据
python·http
NaclarbCSDN2 小时前
Java IO框架
开发语言·python