Jeally Bean中MonekyRunner 帮助文件
基于4.2的SDK导出来的MonkeyRunner的最新帮助,这个版本对MonkeyView和MonkeyRect有了很大的加强,在MonkeyRunner的易用性上有了很大的提高。
对于导出MonkeyRunner帮助文件的方法也顺便说一下
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
content = MonkeyRunner.help("html");
f = open('help.html', 'w');
f.write(content);
f.close();
文件会生成在SDK的tools 目录下
MonkeyRunner Help
Table of Contents
- com.android.monkeyrunner.MonkeyRunner.alert
- com.android.monkeyrunner.MonkeyDevice.broadcastIntent
- com.android.monkeyrunner.MonkeyRunner.choice
- com.android.monkeyrunner.MonkeyImage.convertToBytes
- com.android.monkeyrunner.MonkeyDevice.drag
- com.android.monkeyrunner.MonkeyView.getAccessibilityIds
- com.android.monkeyrunner.MonkeyRect.getCenter
- com.android.monkeyrunner.MonkeyView.getChecked
- com.android.monkeyrunner.MonkeyView.getChildren
- com.android.monkeyrunner.MonkeyView.getEnabled
- com.android.monkeyrunner.MonkeyView.getFocused
- com.android.monkeyrunner.MonkeyRect.getHeight
- com.android.monkeyrunner.MonkeyDevice.getHierarchyViewer
- com.android.monkeyrunner.MonkeyView.getLocation
- com.android.monkeyrunner.MonkeyView.getParent
- com.android.monkeyrunner.MonkeyDevice.getProperty
- com.android.monkeyrunner.MonkeyDevice.getPropertyList
- com.android.monkeyrunner.MonkeyImage.getRawPixel
- com.android.monkeyrunner.MonkeyImage.getRawPixelInt
- com.android.monkeyrunner.MonkeyDevice.getRootView
- com.android.monkeyrunner.MonkeyView.getSelected
- com.android.monkeyrunner.MonkeyImage.getSubImage
- com.android.monkeyrunner.MonkeyDevice.getSystemProperty
- com.android.monkeyrunner.MonkeyView.getText
- com.android.monkeyrunner.MonkeyDevice.getViewByAccessibilityIds
- com.android.monkeyrunner.MonkeyDevice.getViewById
- com.android.monkeyrunner.MonkeyView.getViewClass
- com.android.monkeyrunner.MonkeyDevice.getViewIdList
- com.android.monkeyrunner.MonkeyDevice.getViewsByText
- com.android.monkeyrunner.MonkeyRect.getWidth
- com.android.monkeyrunner.MonkeyRunner.help
- com.android.monkeyrunner.MonkeyRunner.input
- com.android.monkeyrunner.MonkeyDevice.installPackage
- com.android.monkeyrunner.MonkeyDevice.instrument
- com.android.monkeyrunner.MonkeyRunner.loadImageFromFile
- com.android.monkeyrunner.MonkeyDevice.press
- com.android.monkeyrunner.MonkeyDevice.reboot
- com.android.monkeyrunner.MonkeyDevice.removePackage
- com.android.monkeyrunner.MonkeyImage.sameAs
- com.android.monkeyrunner.MonkeyView.setFocused
- com.android.monkeyrunner.MonkeyView.setSelected
- com.android.monkeyrunner.MonkeyDevice.shell
- com.android.monkeyrunner.MonkeyRunner.sleep
- com.android.monkeyrunner.MonkeyDevice.startActivity
- com.android.monkeyrunner.MonkeyDevice.takeSnapshot
- com.android.monkeyrunner.MonkeyDevice.touch
- com.android.monkeyrunner.MonkeyDevice.type
- com.android.monkeyrunner.MonkeyRunner.waitForConnection
- com.android.monkeyrunner.MonkeyDevice.wake
- com.android.monkeyrunner.MonkeyImage.writeToFile
com.android.monkeyrunner.MonkeyRunner.alert
Display an alert dialog to the process running the current script. The dialog is modal, so the script stops until the user dismisses the dialog.
Args
- message - The message to display in the dialog.
- title - The dialog's title. The default value is 'Alert'.
- okTitle - The text to use in the dialog button. The default value is 'OK'.
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.broadcastIntent
Sends a broadcast intent to the device.
Args
- uri - The URI for the Intent.
- action - The action for the Intent.
- data - The data URI for the Intent
- mimetype - The mime type for the Intent.
- categories - An iterable of category names for the Intent.
- extras - A dictionary of extras to add to the Intent. Types of these extras are inferred from the python types of the values.
- component - The component of the Intent.
- flags - An iterable of flags for the Intent.All arguments are optional. The default value for each argument is null.(see android.content.Context.sendBroadcast(Intent))
Returns
returns nothing.
com.android.monkeyrunner.MonkeyRunner.choice
Display a choice dialog that allows the user to select a single item from a list of items.
Args
- message - The prompt message to display in the dialog.
- choices - An iterable Python type containing a list of choices to display
- title - The dialog's title. The default is 'Input'
Returns
The 0-based numeric offset of the selected item in the iterable.
com.android.monkeyrunner.MonkeyImage.convertToBytes
Converts the MonkeyImage into a particular format and returns the result as a String. Use this to get access to the rawpixels in a particular format. String output is for better performance.
Args
- format - The destination format (for example, 'png' for Portable Network Graphics format). The default is png.
Returns
The resulting image as a String.
com.android.monkeyrunner.MonkeyDevice.drag
Simulates dragging (touch, hold, and move) on the device screen.
Args
- start - The starting point for the drag (a tuple (x,y) in pixels)
- end - The end point for the drag (a tuple (x,y) in pixels
- duration - Duration of the drag in seconds (default is 1.0 seconds)
- steps - The number of steps to take when interpolating points. (default is 10)
Returns
returns nothing.
com.android.monkeyrunner.MonkeyView.getAccessibilityIds
Returns the accessibility ids of the current view
com.android.monkeyrunner.MonkeyRect.getCenter
Returns a two item list that contains the x and y value of the center of the rectangle
com.android.monkeyrunner.MonkeyView.getChecked
Get the checked status of the view
com.android.monkeyrunner.MonkeyView.getChildren
Returns the children of the current view
com.android.monkeyrunner.MonkeyView.getEnabled
Returns the enabled status of the view
com.android.monkeyrunner.MonkeyView.getFocused
Returns the focused status of the view
com.android.monkeyrunner.MonkeyRect.getHeight
Returns the height of the rectangle
com.android.monkeyrunner.MonkeyDevice.getHierarchyViewer
Get the HierarchyViewer object for the device.
com.android.monkeyrunner.MonkeyView.getLocation
Returns the location of the view in the form of a MonkeyRect
com.android.monkeyrunner.MonkeyView.getParent
Returns the parent of the current view
com.android.monkeyrunner.MonkeyDevice.getProperty
Given the name of a variable on the device, returns the variable's value
Args
- key - The name of the variable. The available names are listed in http://developer.android.com/guide/topics/testing/monkeyrunner.html.
Returns
The variable's value
com.android.monkeyrunner.MonkeyDevice.getPropertyList
Retrieve the properties that can be queried
com.android.monkeyrunner.MonkeyImage.getRawPixel
Get a single ARGB (alpha, red, green, blue) pixel at location x,y. The arguments x and y are 0-based, expressed in pixel dimensions. X increases to the right, and Y increases towards the bottom. This method returns a tuple.
Args
- x - the x offset of the pixel
- y - the y offset of the pixel
Returns
A tuple of (A, R, G, B) for the pixel. Each item in the tuple has the range 0-255.
com.android.monkeyrunner.MonkeyImage.getRawPixelInt
Get a single ARGB (alpha, red, green, blue) pixel at location x,y. The arguments x and y are 0-based, expressed in pixel dimensions. X increases to the right, and Y increases towards the bottom. This method returns an Integer.
Args
- x - the x offset of the pixel
- y - the y offset of the pixel
Returns
An unsigned integer pixel for x,y. The 8 high-order bits are A, followedby 8 bits for R, 8 for G, and 8 for B.
com.android.monkeyrunner.MonkeyDevice.getRootView
Obtains current root view
com.android.monkeyrunner.MonkeyView.getSelected
Returns the selected status of the view
com.android.monkeyrunner.MonkeyImage.getSubImage
Copy a rectangular region of the image.
Args
- rect - A tuple (x, y, w, h) describing the region to copy. x and y specify upper lefthand corner of the region. w is the width of the region in pixels, and h is its height.
Returns
a MonkeyImage object representing the copied region.
com.android.monkeyrunner.MonkeyDevice.getSystemProperty
Synonym for getProperty()
Args
- key - The name of the system variable.
Returns
The variable's value.
com.android.monkeyrunner.MonkeyView.getText
Returns the text contained by the view
com.android.monkeyrunner.MonkeyDevice.getViewByAccessibilityIds
Obtains the view with the specified accessibility ids.
Args
- windowId - The window id of the view to retrieve.
- accessibility id - The accessibility id of the view to retrieve.
Returns
The view object with the specified id.
com.android.monkeyrunner.MonkeyDevice.getViewById
Obtains the view with the specified id.
Args
- id - The id of the view to retrieve.
Returns
The view object with the specified id.
com.android.monkeyrunner.MonkeyView.getViewClass
Returns the class name of the view
com.android.monkeyrunner.MonkeyDevice.getViewIdList
Retrieve the view ids for the current application
com.android.monkeyrunner.MonkeyDevice.getViewsByText
Obtains a list of views that contain the specified text.
Args
- text - The text to search for
Returns
A list of view objects that contain the specified text.
com.android.monkeyrunner.MonkeyRect.getWidth
Returns the width of the rectangle
com.android.monkeyrunner.MonkeyRunner.help
Format and display the API reference for MonkeyRunner.
Args
- format - The desired format for the output, either 'text' for plain text or 'html' for HTML markup.
Returns
A string containing the help text in the desired format.
com.android.monkeyrunner.MonkeyRunner.input
Display a dialog that accepts input. The dialog is ,modal, so the script stops until the user clicks one of the two dialog buttons. To enter a value, the user enters the value and clicks the 'OK' button. To quit the dialog without entering a value, the user clicks the 'Cancel' button. Use the supplied arguments for this method to customize the text for these buttons.
Args
- message - The prompt message to display in the dialog.
- initialValue - The initial value to supply to the user. The default is an empty string)
- title - The dialog's title. The default is 'Input'
- okTitle - The text to use in the dialog's confirmation button. The default is 'OK'.The text to use in the dialog's 'cancel' button. The default is 'Cancel'.
- cancelTitle -
Returns
The test entered by the user, or None if the user canceled the input;
com.android.monkeyrunner.MonkeyDevice.installPackage
Installs the specified Android package (.apk file) onto the device. If the package already exists on the device, it is replaced.
Args
- path - The package's path and filename on the host filesystem.
Returns
True if the install succeeded
com.android.monkeyrunner.MonkeyDevice.instrument
Run the specified package with instrumentation and return the output it generates. Use this to run a test package using InstrumentationTestRunner.
Args
- className - The class to run with instrumentation. The format is packagename/classname. Use packagename to specify the Android package to run, and classname to specify the class to run within that package. For test packages, this is usually testpackagename/InstrumentationTestRunner
- args - A map of strings to objects containing the arguments to pass to this instrumentation (default value is None).
Returns
A map of strings to objects for the output from the package. For a test package, contains a single key-value pair: the key is 'stream' and the value is a string containing the test output.
com.android.monkeyrunner.MonkeyRunner.loadImageFromFile
Loads a MonkeyImage from a file.
Args
- path - The path to the file to load. This file path is in terms of the computer running MonkeyRunner and not a path on the Android Device.
Returns
A new MonkeyImage representing the specified file
com.android.monkeyrunner.MonkeyDevice.press
Send a key event to the specified key
Args
- name - the keycode of the key to press (see android.view.KeyEvent)
- type - touch event type as returned by TouchPressType(). To simulate typing a key, send DOWN_AND_UP
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.reboot
Reboots the specified device into a specified bootloader.
Args
- into - the bootloader to reboot into: bootloader, recovery, or None
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.removePackage
Deletes the specified package from the device, including its associated data and cache.
Args
- package - The name of the package to delete.
Returns
True if remove succeeded
com.android.monkeyrunner.MonkeyImage.sameAs
Compare this MonkeyImage object to aother MonkeyImage object.
Args
- other - The other MonkeyImage object.
- percent - A float in the range 0.0 to 1.0, indicating the percentage of pixels that need to be the same for the method to return 'true'. Defaults to 1.0.
Returns
boolean 'true' if the two objects contain the same image.
com.android.monkeyrunner.MonkeyView.setFocused
Sets the focused status of the view
Args
- focused - The boolean value to set focused to
Returns
returns nothing.
com.android.monkeyrunner.MonkeyView.setSelected
Sets the selected status of the view
Args
- selected - The boolean value to set selected to
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.shell
Executes an adb shell command and returns the result, if any.
Args
- cmd - The adb shell command to execute.
Returns
The output from the command.
com.android.monkeyrunner.MonkeyRunner.sleep
Pause the currently running program for the specified number of seconds.
Args
- seconds - The number of seconds to pause.
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.startActivity
Starts an Activity on the device by sending an Intent constructed from the specified parameters.
Args
- uri - The URI for the Intent.
- action - The action for the Intent.
- data - The data URI for the Intent
- mimetype - The mime type for the Intent.
- categories - A Python iterable containing the category names for the Intent.
- extras - A dictionary of extras to add to the Intent. Types of these extras are inferred from the python types of the values.
- component - The component of the Intent.
- flags - An iterable of flags for the Intent.All arguments are optional. The default value for each argument is null.(see android.content.Intent)
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.takeSnapshot
Gets the device's screen buffer, yielding a screen capture of the entire display.
com.android.monkeyrunner.MonkeyDevice.touch
Sends a touch event at the specified location
Args
- x - x coordinate in pixels
- y - y coordinate in pixels
- type - touch event type as returned by TouchPressType()
Returns
returns nothing.
com.android.monkeyrunner.MonkeyDevice.type
Types the specified string on the keyboard. This is equivalent to calling press(keycode,DOWN_AND_UP) for each character in the string.
Args
- message - The string to send to the keyboard.
Returns
returns nothing.
com.android.monkeyrunner.MonkeyRunner.waitForConnection
Waits for the workstation to connect to the device.
Args
- timeout - The timeout in seconds to wait. The default is to wait indefinitely.
- deviceId - A regular expression that specifies the device name. See the documentation for 'adb' in the Developer Guide to learn more about device names.
Returns
A ChimpDevice object representing the connected device.
com.android.monkeyrunner.MonkeyDevice.wake
Wake up the screen on the device
com.android.monkeyrunner.MonkeyImage.writeToFile
Write the MonkeyImage to a file. If no format is specified, this method guesses the output format based on the extension of the provided file extension. If it is unable to guess the format, it uses PNG.
Args
- path - The output filename, optionally including its path
- format - The destination format (for example, 'png' for Portable Network Graphics format.
Returns
boolean true if writing succeeded.
Jeally Bean中MonekyRunner 帮助文件的更多相关文章
- Spring依赖注入的方式、类型、Bean的作用域、自动注入、在Spring配置文件中引入属性文件
1.Spring依赖注入的方式 通过set方法完成依赖注入 通过构造方法完成依赖注入 2.依赖注入的类型 基本数据类型和字符串 使用value属性 如果是指向另一个对象的引入 使用ref属性 User ...
- 五种方式让你在java中读取properties文件内容不再是难题
一.背景 最近,在项目开发的过程中,遇到需要在properties文件中定义一些自定义的变量,以供java程序动态的读取,修改变量,不再需要修改代码的问题.就借此机会把Spring+SpringMVC ...
- spring的显示装配bean(1)------通过XML文件装配
1:spring环境的简单搭建 (1)导入spring相关的jar包. 2:准备要进行装配的Java类 这里给出两个举例类 (1) (2) 3:配置XML文件 (1)在配置文件的顶部声明多个XML模式 ...
- Spring中MultipartHttpServletRequest实现文件上传
Spring中MultipartHttpServletRequest实现文件上传 转贴自:http://my.oschina.net/nyniuch/blog/185266 实现图片上传 用户必须能 ...
- ANT 发布项目中 build.xml 文件的详细配置
xml 代码 <?xml version="1.0" encoding="UTF-8"?> <!-- name:对应工程名字 default: ...
- Spring bean中的properties元素内的name 和 ref都代表什么意思啊?
<bean id="userAction" class="com.neusoft.gmsbs.gms.user.action.UserAction" sc ...
- spring mvc: 可参数化的视图控制器(在配置中指定jsp文件)MultiActionController/SimpleUrlHandlerMapping/ParameterizableViewController
spring mvc: 可参数化的视图控制器(在配置中指定jsp文件)MultiActionController/SimpleUrlHandlerMapping/ParameterizableView ...
- Spring MVC中 log4j日志文件配置相对路径
log4j和web.xml配置webAppRootKey 的问题 1 在web.xml配置 <context-param> <param-name>webAppRootKey ...
- Spring中的applicationContext文件详解
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
随机推荐
- C++排序函数sort/qsort使用
问题描述: C++排序函数sort/qsort的使用 问题解决: (1)sort函数使用 注: sort函数,参数1为数组首地址,参数2是数组 ...
- 使用了非标准扩展:“xxx”使用 SEH,并且“xxx”有析构函数
如果一个函数内使用了异常处理机制, VC 编译器在编译该函数时,它会给此函数插入一些“代码和信息”(代码指的是当该函数中出现异常时的回调函数,而信息主要是指与异常出现相关的一些必要的链表),因此每份函 ...
- 01-08-01【Nhibernate (版本3.3.1.4000) 出入江湖】NHibernate中的三种状态
以下属于不明来源资料: 引入 在程序运行过程中使用对象的方式对数据库进行操作,这必然会产生一系列的持久化类的实例对象.这些对象可能是刚刚创建并准备存储的,也可能是从数据库中查询的,为了区分这些对象,根 ...
- sigleSchool 存储过程例1
CREATE OR REPLACE PROCEDURE SINGLSCHOOL( PICIID IN VARCHAR2, SCHOOLID IN NUMBER, SCHETYPE IN number, ...
- centos telnet --xinetd 服务
telnet由于是明文传输,所以安全起见最好不要用telnet服务.但是由于telnet是一个比较方便的远程工具,在windows上是自带 的不需要安装客户端即可使用.如果telnet设置的比较复杂, ...
- Spring Boot 快速入门
Spring Boot 快速入门 http://blog.csdn.net/xiaoyu411502/article/details/47864969 今天给大家介绍一下Spring Boot MVC ...
- auto_ptr的设计动机
auto_ptr的设计动机 C++标准程序库提供的auto_ptr是一种智能型指针(smart pointer),帮助程序员防止“被异常抛出时发生资源泄露”. 函数的操作经常依以下模式进行: 1.获取 ...
- ***CI分页:为CodeIgniter写的分页类
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ...
- lintcode: 三数之和II
题目 三数之和 II 给一个包含n个整数的数组S, 找到和与给定整数target最接近的三元组,返回这三个数的和. 样例 例如S = . 和最接近1的三元组是 -1 + 2 + 1 = 2. 注意 ...
- lintcode :链表插入排序
题目: 链表插入排序 用插入排序对链表排序 样例 Given 1->3->2->0->null, return 0->1->2->3->null 解题: ...