想在粘贴板写数据,让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"