首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在shell (终端)中执行monkeyrunner命令

如何在shell (终端)中执行monkeyrunner命令
EN

Stack Overflow用户
提问于 2011-12-21 09:01:38
回答 1查看 2.5K关注 0票数 0

当我从壳开始我的纸条时我会做这样的事情

代码语言:javascript
代码运行次数:0
运行
复制
monkeyrunner myScriptFile

然后

在myScriptFile中,我有这样的内容

代码语言:javascript
代码运行次数:0
运行
复制
    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”命令?

EN

回答 1

Stack Overflow用户

发布于 2012-02-23 11:47:00

要安装软件包,您可以使用monkeyrunneradb install -r 'myproject/bin/MyApplication.apk'

  • if代替脚本,您可以使用shell这里的字符串语法来避免使用monkeyrunner脚本的单独文件:

代码语言:javascript
代码运行次数:0
运行
复制
#!/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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8587258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档