Android自动测试之MonkeyRunner之MonkeyImage

本文介绍如何利用monkeyrunner类保存设备或模拟器的截图,并通过MonkeyImage对象进行图像转换、存储和复制操作,便于进行问题观察。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

monkeyrunner类可以保存设备或模拟器的截图。MonkeyImage提供了图像转换、图像存储、复制部分图像能方法。这样可以把通过截图显性的观察问题。

      MonkeyImage创建对象的方法如下:

             newimage =MonkeyDevice.takeSnapshot()

     MonkeyImage提供了如下方法:

 

Methods
stringconvertToBytes                (string format)
                Converts the current image to a particular format and returns it as a                string that you can then access as an iterable of binary bytes.           
tuplegetRawPixel                (integer x,               integer y)           
                Returns the single pixel at the image location (x,y), as an                a tuple of integer, in the form (a,r,g,b).           
integergetRawPixelInt                (integer x,                integer y)           
                Returns the single pixel at the image location (x,y), as                a 32-bit integer.           
MonkeyImagegetSubImage                (tuple rect)           
                Creates a new MonkeyImage object from a rectangular selection of the                current image.           
booleansameAs         (MonkeyImage            other,            float percent)           
                Compares this MonkeyImage object to another and returns the result of                the comparison. The percent argument specifies the percentage                difference that is allowed for the two images to be "equal".           
voidwriteToFile                (string path,               string format)           
                Writes the current image to the file specified by filename, in the                format specified by format.           

     

     http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html

 

 

/**
* @author 张兴业
* 邮箱:xy-zhang@163.com
* qq:363302850
*
*/

转载于:https://www.cnblogs.com/xyzlmn/archive/2011/10/24/3168414.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值