Android自动化测试之MonkeyRunner之MonkeyRunner

A monkeyrunner class that contains static utility methods.

Summary

Methods
void alert( string message, string title, string okTitle)Displays an alert dialog to the process running the current program.
integer choice( string message, iterable choices, string title)Displays a dialog with a list of choices to the process running the current program.
void help( string format)Displays the monkeyrunner API reference in a style similar to that of Python'spydoc tool, using the specified format.
string input( string message, string initialValue, string title, string okTitle, string cancelTitle)Displays a dialog that accepts input.
void sleep( float seconds)Pauses the current program for the specified number of seconds.
MonkeyDevice waitForConnection( float timeout, string deviceId)Tries to make a connection between themonkeyrunner backend and the specified device or emulator.

Public Methods

string alert(string message,string title,string okTitle)

Displays an alert dialog to the process running the current program. The dialog is modal, so the program pauses until the user clicks the dialog's button.

Arguments
messageThe message to display in the dialog.
titleThe dialog's title. The default value is "Alert".
okTitleThe text displayed in the dialog button. The default value is "OK".

integer choice(string message,iterable choices,string title)

Displays a dialog with a list of choices to the process running the current program. The dialog is modal, so the program pauses until the user clicks one of the dialog's buttons.

Arguments
messageThe prompt message displayed in the dialog.
choicesA Python iterable containing one or more objects that are displayed as strings. The recommended form is an array of strings.
titleThe dialog's title. The default is "Input".
Returns
  • If the user makes a selection and clicks the "OK" button, the method returns the 0-based index of the selection within the iterable. If the user clicks the "Cancel" button, the method returns -1.

void help(string format)

Displays the monkeyrunner API reference in a style similar to that of Python'spydoc tool, using the specified format.

Arguments
formatThe markup format to use in the output. The possible values are "text" for plain text or "html" for HTML.

string input(string messagestring initialValue,string title,string okTitle,string cancelTitle)

Displays a dialog that accepts input and returns it to the program. The dialog is modal, so the program pauses until the user clicks one of the dialog's buttons.

The dialog contains two buttons, one of which displays the okTitle value and the other the cancelTitle value. If the user clicks the okTitle button, the current value of the input box is returned. If the user clicks the cancelTitle button, an empty string is returned.

Arguments
messageThe prompt message displayed in the dialog.
initialValueThe initial value to display in the dialog. The default is an empty string.
titleThe dialog's title. The default is "Input".
okTitleThe text displayed in the okTitle button. The default is "OK".
cancelTitleThe text displayed in the cancelTitle button. The default is "Cancel".
Returns
  • If the user clicks the okTitle button, then the method returns the current value of the dialog's input box. If the user clicks the cancelTitle button, the method returns an empty string.

void sleep(float seconds )

Pauses the current program for the specified number of seconds.

Arguments
secondsThe number of seconds to pause.

MonkeyDevicewaitForConnection(float timeout,string deviceId)

Tries to make a connection between the monkeyrunner backend and the specified device or emulator.

Arguments
timeoutThe number of seconds to wait for a connection. The default is to wait forever.
deviceIdA regular expression that specifies the serial number of the device or emulator. See the topicAndroid Debug Bridge for a description of device and emulator serial numbers.
Returns
  • A MonkeyDevice instance for the device or emulator. Use this object to control and communicate with the device or emulator.

参考:http://developer.android.com/tools/help/MonkeyRunner.html

更多相关文章

  1. Android单元测试Unable to find instrumentation target package
  2. android的单元测试摘要
  3. Android自动化测试之MonkeyRunner之MonkeyImage(十)
  4. Android单元测试和日志输出
  5. google Android 认证测试
  6. android 7.0 系统关闭彩信过CTA测试的方法
  7. android单元测试 配置注意
  8. Android 4.0.3 CTS 测试

随机推荐

  1. Android中利用Handler实现消息的分发机制
  2. 【Android 设计】:样式_ 图解
  3. Android Bitmap转Drawable
  4. ubuntu 10.04/ubuntu 12.04 /ubuntu 13.0
  5. android中的左右滑屏实现By ViewPager
  6. Android网络编程Demo
  7. Android Studio 2.0 Instant Run无效(Inst
  8. Android属性 gravity, layout_gravity, p
  9. 第23章、OnFocuChangeListener焦点事件(从
  10. 新版eclipse编写Android 时经常报的错误