MonkeyDevice是
用来控制Android设备或模拟器,发送UI事件的方法,检索信息,安装和删除应用程序,并可以运行应用程序。 通常,不必使用newdevice
= MonkeyDevice()来创建MonkeyDevice的一个实例。相反的经常使用MonkeyRunner.waitForConnection()来创建一个新的MonkeyDevice对象。
MonkeyDevice的常用方法:
Summary
Constants
string |
DOWN |
Use this with the type argument ofpress() ortouch()
to send a DOWN event. |
string |
UP |
Use this with the type argument ofpress() ortouch()
to send an UP event. |
string |
DOWN_AND_UP |
Use this with the type argument ofpress() ortouch()
to send a DOWN event immediately followed by an UP event. |
Methods
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#broadcastIntent" target="_blank">broadcastIntent</a></span> (<em>string</em> uri,<em>string</em>
action, <em>string</em> data, <em>string</em> mimetype,<em>iterable</em> categories
<em>dictionary</em> extras,<em>component</em> component,
<em>iterable</em> flags) </nobr> Broadcasts an Intent to this device, as if the Intent were coming from an application.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#drag" target="_blank">drag</a></span> (<em>tuple</em> start,<em>tuple</em> end,
<em>float</em> duration, <em>integer</em> steps)</nobr> Simulates a drag gesture (touch, hold, and move) on this device's screen.
|
<nobr><em>object</em></nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#getProperty" target="_blank">getProperty</a></span> (<em>string</em> key)</nobr> Given the name of a system environment variable, returns its value for this device. The available variable names are listed in the
detailed description of this method.
|
<nobr><em>object</em></nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#getSystemProperty" target="_blank">getSystemProperty</a></span> (<em>string</em> key)</nobr> . The API equivalent of adb shell getprop <key>. This is provided for use by platform developers.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#installPackage" target="_blank">installPackage</a></span> (<em>string</em> path)</nobr> Installs the Android application or test package contained in packageFile onto this device. If the application or test package is already installed, it is replaced.
|
<nobr><em>dictionary</em></nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#instrument" target="_blank">instrument</a></span> (<em>string</em> className,<em>dictionary</em>
args) </nobr> Runs the specified component under Android instrumentation, and returns the results in a dictionary whose exact format is dictated by the component being run. The component must already
be present on this device.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#press" target="_blank">press</a></span> (<em>string</em> name,<em>dictionary</em>
type) </nobr> Sends the key event specified by type to the key specified by keycode.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#reboot" target="_blank">reboot</a></span> (<em>string</em> into)</nobr> Reboots this device into the bootloader specified by bootloadType.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#removePackage" target="_blank">removePackage</a></span> (<em>string</em> package)</nobr> Deletes the specified package from this device, including its data and cache.
|
<nobr><em>object</em></nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#shell" target="_blank">shell</a></span> (<em>string</em> cmd)</nobr> Executes an adb shell command and returns the result, if any.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#startActivity" target="_blank">startActivity</a></span> (<em>string</em> uri,<em>string</em>
action, <em>string</em> data, <em>string</em> mimetype,<em>iterable</em> categories
<em>dictionary</em> extras,<em>component</em> component,
<em>flags</em>) </nobr> Starts an Activity on this device by sending an Intent constructed from the supplied arguments.
|
<nobr><code><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html" target="_blank"> MonkeyImage</a></code></nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#takeSnapshot" target="_blank">takeSnapshot</a>()</span></nobr> Captures the entire screen buffer of this device, yielding a MonkeyImage object
containing a screen capture of the current display.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#touch" target="_blank">touch</a></span> (<em>integer</em> x,<em>integer</em> y,
<em>integer</em> type) </nobr> Sends a touch event specified by type to the screen location specified by x and y.
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#touch" target="_blank">type</a></span> (<em>string</em> message)</nobr> Sends the characters contained in message to this device, as if they had been typed on the device's keyboard. This is equivalent to calling press()
for each keycode in message using the key event type
DOWN_AND_UP .
|
<nobr> void </nobr> |
<nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html#touch" target="_blank">wake</a></span> ()</nobr> Wakes the screen of this device.
|
http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html
/**
* @author 张兴业
* 邮箱:xy-zhang@163.com
* qq:363302850
*
*/
分享到:
相关推荐
Android自动测试之monkeyrunner工具.docxAndroid自动测试之monkeyrunner工具.docx
知识共享-Android自动测试之monkeyrunner工具(雷惊风).
android自动化测试monkeyrunner的入门使用教程,讲解了如何使用monkeyrunner进行android的自动化测试
monkeyrunner工具提供一个API来控制Android设备。可以写一个python脚本来安装应用,运行应用,发送键值,截图。monkeyrunner对python进行了封装,加入了一些针对Android设备的类。可以完全用python脚本来实现这些...
Android自动化测试之MonkeyRunner--从环境构建、参数讲解、脚本制作到实战技巧
Android自动化测试之Monkeyrunner常用操作编程 本篇乃本人学习monkeyrunner时笔记,查看网络中的资料并经本人测试而出,由于本人刚接触,所以本篇内容不免肤浅,高手们请绕走~ 在测试本人以下实例时,请自行搭建...
Android自动化测试(MonkeyRunner)脚本
详细介绍了如何搭建Android自动化测试环境以及使用Monkeyrunner进行自动化测试的方法。
该文档包含了本人对android自动化测试工具monkeyrunner的一些总结,有需要的可以看看。
前言:最近开始研究Android自动化测试方法,对其中的一些工具、方法和框架做了一些简单的整理,其中包括android测试框架、CTS、Monkey、Monkeyrunner、benchmark、其它testtool等等。因接触时间很短,很多地方有不足...
测验自己开拓的Android利用过程之monkeyrunner.docx测验自己开拓的Android利用过程之monkeyrunner.docx
用于测试Android计算器,适合初学monkeyrunner测试脚本编写者
Android自动测试之monkeyrunner工具 Android自动测试之Monkey工具 Android自动化测试初探 Android自动化测试可行性途径分析 Android自动化测试之道 GSM手机自动化测试解决方案 手机自动化测试系统设计浅析 在...
比较了monkeyrunner和monkey这两个好兄弟,同时把monkeyrunner实现的脚本集成到eclipse-pydev的环境中运行
主要描述如何使用monkeyrunner,以及脚本的使用
本文主要通过PPT的方式来介绍APP自动化相关知识,并且以MonKeyRunner为例讲解如何通过MonKeyRunner实战操作自动化测试
该文档适用于android平台项目的软件自动化测试,本文档描述了Monkeyrunner环境配置和具体使用教程,可供学习
MonkeyRunner也是Android SDK提供的测试工具 基于Java Instrumentation是早期Google提供的Android自动化测试工具类 UiAutomator也是Android提供的自动化测试框架,基本上支持所有的Android事件操作 Espresso,...
NULL 博文链接:https://myeyeofjava.iteye.com/blog/1561738
非扫描版 带书签许奔 著ISBN:978-7-111-52120-4目录本书赞誉前言第一部分 基础篇第1章 Android自动化测试基础1.1 Android自动化分析1.2 什么样的兵器最称手1.3 如何耍好你手上的兵器1.4 你了解你的兵器吗1.5...