当我从壳开始我的纸条时我会做这样的事情
monkeyrunner myScriptFile
然后
在myScriptFile中,我有这样的内容
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
device.installPackage('myproject/bin/MyApplication.apk')
.....
一切都很好,但是我想做一些更花哨的事情:),我想从终端(Shell)写所有的东西
那么用shell编写所有东西是可能的吗?我的意思是,用myScriptFile编写的命令有可能直接在shell中执行,而不需要像myScriptFile这样的附加文件。
或者,是否可以在shell中执行“from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice”命令?
发布于 2012-02-23 03:47:00
要安装软件包,您可以使用monkeyrunneradb install -r 'myproject/bin/MyApplication.apk'
#!/bin/bash
./monkeyrunner <<EOL
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# Takes a screenshot
result = device.takeSnapshot()
# Writes the screenshot to a file
result.writeToFile('1.png','png')
EOL
https://stackoverflow.com/questions/8587258
复制