android自动化测试monkey,Android自动化测试之MonkeyRunner之MonkeyDevice

A monkeyrunner class that represents a device or emulator accessible by the workstation running monkeyrunner.

This class is used to control an Android device or emulator. The methods send UI events, retrieve information, install and remove applications, and run applications.

You normally do not have to create an instance of MonkeyDevice. Instead, you useMonkeyRunner.waitForConnection() to create a new object from a connection to a device or emulator. For example, instead of using:newdevice=MonkeyDevice()

you would use:newdevice=MonkeyRunner.waitForConnection()

Summary

Constants

stringDOWNUse this with the type argument ofpress() ortouch()to send a DOWN event.

stringUPUse this with the type argument ofpress() ortouch()to send an UP event.

stringDOWN_AND_UPUse this with the type argument ofpress() ortouch()to send a DOWN event immediately followed by an UP event.Methods

voidbroadcastIntent(string uri,string action,string data,string mimetype,iterable categoriesdictionary extras,component component,iterable flags)

Broadcasts an Intent to this device, as if the Intent were coming from an application.

voiddrag(tuple start,tuple end,float duration,integer steps)

Simulates a drag gesture (touch, hold, and move) on this device's screen.

objectgetProperty(string key)

Given the name of a system environment variable, returns its value for this device. The available variable names are listed in thedetailed description of this method.

objectgetSystemProperty(string key)

. The API equivalent of adb shell getprop . This is provided for use by platform developers.

voidinstallPackage(string path)

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.

dictionaryinstrument(string className,dictionary args)

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.

voidpress(string name,dictionary type)

Sends the key event specified by type to the key specified by keycode.

voidreboot(string into)

Reboots this device into the bootloader specified by bootloadType.

voidremovePackage(string package)

Deletes the specified package from this device, including its data and cache.

objectshell(string cmd)

Executes an adb shell command and returns the result, if any.

voidstartActivity(string uri,string action,string data,string mimetype,iterable categoriesdictionary extras,component component,flags)

Starts an Activity on this device by sending an Intent constructed from the supplied arguments.

MonkeyImagetakeSnapshot()

Captures the entire screen buffer of this device, yielding aMonkeyImageobject containing a screen capture of the current display.

voidtouch(integer x,integer y,integer type)

Sends a touch event specified by type to the screen location specified by x and y.

voidtype(string message)

Sends the characters contained in message to this device, as if they had been typed on the device's keyboard. This is equivalent to callingpress() for each keycode inmessage using the key event type DOWN_AND_UP.

voidwake()

Wakes the screen of this device.

Constants

stringDOWN

press() ortouch() value. Specifies that a DOWN event type should be sent to the device, corresponding to pressing down on a key or touching the screen.

stringUP

press() ortouch() value. Specifies that an UP event type should be sent to the device, corresponding to releasing a key or lifting up from the screen.

stringDOWN_AND_UP

press(),touch() ortype() value. Specifies that a DOWN event type followed by an UP event type should be sent to the device, corresponding to typing a key or clicking the screen.

Public Methods

voidbroadcastIntent(string uri,string action,string data,string mimetype,iterable categoriesdictionary extras,componentcomponent,iterable flags)

Broadcasts an Intent to this device, as if the Intent were coming from an application. SeeIntent for more information about the arguments.

ArgumentsuriThe URI for the Intent. (see Intent.setData()).

actionThe action for this Intent (see Intent.setAction()).

dataThe data URI for this Intent (see Intent.setData()).

mimetypeThe MIME type for the Intent (see Intent.setType()).

categoriesAn iterable data structure containing strings that define categories for this Intent (seeIntent.addCategory()).

extrasA dictionary of extra data for this Intent (see Intent.putExtra() for an example).

The key for each dictionary item should be a string. The item's value can be any simple or structured data type.

componentThe component for this Intent (see ComponentName). Using this argument will direct the Intent to a specific class within a specific Android package.

flagsAn iterable data structure containing flags that control how the Intent is handled (seeIntent.setFlags()).

voiddrag(tuple start,tuple end,float duration,integer steps)

Simulates a drag gesture (touch, hold, and move) on this device's screen.

ArgumentsstartThe starting point of the drag gesture, in the form of a tuple (x,y) where x and y areintegers.

endThe end point of the drag gesture, in the form of a tuple (x,y) where x and y areintegers.

durationThe duration of the drag gesture in seconds. The default is 1.0 seconds.

stepsThe number of steps to take when interpolating points. The default is 10.

objectgetProperty(string key)

Given the name of a system environment variable, returns its value for this device.

ArgumentskeyThe name of the system environment variable. The available variable names are listed inTable 1. Property variable names at the end of this topic.

ReturnsThe value of the variable. The data format varies according to the variable requested.

objectgetSystemProperty(string key)

Synonym for getProperty().

ArgumentskeyThe name of the system environment variable. The available variable names are listed inTable 1. Property Variable Names.

ReturnsThe value of the variable. The data format varies according to the variable requested.

voidinstallPackage(string path)

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.

ArgumentspathThe fully-qualified path and filename of the .apk file to install.

dictionaryinstrument(string className,dictionary args)

Runs the specified component with 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.

Use this method to start a test case that uses one of Android's test case classes. SeeTesting Fundamentals to learn more about unit testing with the Android testing framework.

ArgumentsclassNameThe name of an Android component that is already installed on this device, in the standard form packagename/classname, where packagename is the Android package name of a.apk file on this device, and classname is the class name of an Android component (Activity, ContentProvider, Service, or BroadcastReceiver) in that file. Both packagename and classname must be fully qualified. SeeComponentName for more details.

argsA dictionary containing flags and their values. These are passed to the component as it is started. If the flag does not take a value, set its dictionary value to an empty string.

ReturnsA dictionary containing the component's output. The contents of the dictionary are defined by the component itself.

If you use InstrumentationTestRunner as the class name in the componentName argument, then the result dictionary contains the single key "stream". The value of "stream" is a string containing the test output, as if InstrumentationTestRunner was run from the command line. The format of this output is described inTesting in Other IDEs.

voidpress(string name,integer type)

Sends the key event specified by type to the key specified by keycode.

ArgumentsnameThe name of the keycode to send. See KeyEvent for a list of keycode names. Use the keycode name, not its integer value.

typeThe type of key event to send. The allowed values are DOWN,UP, andDOWN_AND_UP.

voidreboot(string bootloadType)

Reboots this device into the bootloader specified by bootloadType.

ArgumentsintoThe type of bootloader to reboot into. The allowed values are "bootloader", "recovery", or "None".

voidremovePackage(string package)

Deletes the specified package from this device, including its data and cache.

ArgumentspackageThe Android package name of an .apk file on this device.

objectshell(string cmd)

Executes an adb shell command and returns the result, if any.

ArgumentscmdThe command to execute in the adb shell. The form of these commands is described in the topicAndroid Debug Bridge.

ReturnsThe results of the command, if any. The format of the results is determined by the command.

voidstartActivity(string uri,string action,string data,string mimetype,iterable categoriesdictionary extras,componentcomponent,iterable flags)

Starts an Activity on this device by sending an Intent constructed from the supplied arguments.

ArgumentsuriThe URI for the Intent. (see Intent.setData()).

actionThe action for the Intent (see Intent.setAction()).

dataThe data URI for the Intent (see Intent.setData()).

mimetypeThe MIME type for the Intent (see Intent.setType()).

categoriesAn iterable data structure containing strings that define categories for the Intent (seeIntent.addCategory()).

extrasA dictionary of extra data for the Intent (see Intent.putExtra() for an example).

The key for each dictionary item should be a string. The item's value can be any simple or structured data type.

componentThe component for the Intent (see ComponentName). Using this argument will direct the Intent to a specific class within a specific Android package.

flagsAn iterable data structure containing flags that control how the Intent is handled (seeIntent.setFlags()).

MonkeyImagetakeSnapshot()

Captures the entire screen buffer of this device, yielding a screen capture of the current display.

ReturnsA MonkeyImage object containing the image of the current display.

voidtouch(integer x,integer y,string type)

Sends a touch event specified by type to the screen location specified by x and y.

ArgumentsxThe horizontal position of the touch in actual device pixels, starting from the left of the screen in its current orientation.

yThe vertical position of the touch in actual device pixels, starting from the top of the screen in its current orientation.

typeThe type of key event to send. The allowed values are DOWN,UP, andDOWN_AND_UP.

voidtype(string message)

Sends the characters contained in message to this device, as if they had been typed on the device's keyboard. This is equivalent to callingpress() for each keycode inmessage using the key event type DOWN_AND_UP.

ArgumentsmessageA string containing the characters to send.

voidwake()

Wakes the screen of this device.

基于SSM框架的智能家政保洁预约系统,是一个旨在提高家政保洁服务预约效率和管理水平的平台。该系统通过集成现代信息技术,为家政公司、家政服务人员和消费者提供了一个便捷的在线预约和管理系统。 系统的主要功能包括: 1. **用户管理**:允许消费者注册、登录,并管理他们的个人资料和预约历史。 2. **家政人员管理**:家政服务人员可以注册并更新自己的个人信息、服务类别和服务时间。 3. **服务预约**:消费者可以浏览不同的家政服务选项,选择合适的服务人员,并在线预约服务。 4. **订单管理**:系统支持订单的创建、跟踪和管理,包括订单的确认、完成和评价。 5. **评价系统**:消费者可以在家政服务完成后对服务进行评价,帮助提高服务质量和透明度。 6. **后台管理**:管理员可以管理用户、家政人员信息、服务类别、预约订单以及处理用户反馈。 系统采用Java语言开发,使用MySQL数据库进行数据存储,通过B/S架构实现用户与服务的在线交互。系统设计考虑了不同用户角色的需求,包括管理员、家政服务人员和普通用户,每个角色都有相应的权限和功能。此外,系统还采用了软件组件化、精化体系结构、分离逻辑和数据等方法,以便于未来的系统升级和维护。 智能家政保洁预约系统通过提供一个集中的平台,不仅方便了消费者的预约和管理,也为家政服务人员提供了一个展示和推广自己服务的机会。同时,系统的后台管理功能为家政公司提供了强大的数据支持和决策辅助,有助于提高服务质量和管理效率。该系统的设计与实现,标志着家政保洁服务向现代化和网络化的转型,为管理决策和控制提供保障,是行业发展中的重要里程碑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值