airtest如何在剪贴板写数据,写特殊符号&

想在粘贴板写数据,让app打开后读取粘贴板路由,直接跳转目标页
一开始试了win32的复制粘贴,结果不行。猜测是airtest并不支持,也可能是我能力不够,如有他人成功,欢迎留言给我。
后来用adb shell,电脑连接手机,可以成功,但是在airttest中运行有报错
代码如下,

dev = connect_device("android://127.0.0.1:5037/devicexxxxxx")
dev.shell("adb shell am startservice ca.zgrs.clipper/.ClipboardService")
dev.shell("adb shell am broadcast -a clipper.set -e text 'test11111'")
dev.shell("adb shell am broadcast -a clipper.get")

报错airtest.core.error.AdbShellError: stdout[b’’] stderr[b’/system/bin/sh: adb: inaccessible or not found\r\n’]

未找到解决办法,所以换一种写法

connect_device("android://127.0.0.1:5037/devicexxxxxx")
os.system('adb shell am startservice ca.zgrs.clipper/.ClipboardService')
os.system('adb shell am broadcast -a clipper.set -e text "test0://test1\&test2"')
os.system("adb shell am broadcast -a clipper.get")

另外:
adb shell 输入特殊字符 & 时,直接提示Kill了,什么都没输入

需要在 & 前面输入转译符  \

adb shell am broadcast -a clipper.set -e text "test0://test1\&test2"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值