1. boolean writeToFile(string path,string format)
boolean true if writing succeeded.
·string path,存储全路径,包括文件扩展名。 ·string format,存储格式。
1) 先调用monkeyDevice中的takeSnapshot方法
2) 在调用MonkeyImage中的writeToFile确认是否成功
e.g.
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
path='./qq.png'
format='png'
device= MonkeyRunner.waitForConnection()
picture = device.takeSnapshot()
picture.writeToFile(path,format)
2. MonkeyImage getSubImage(tuple rect)
tuple rect:进行数组,即所选区域图像
该矩形元组由x,y,w,h组成,其中x和y为矩形左上角坐标点,w为矩形宽度,h为矩形高度。
3.
boolean sameAs(MonkeyImage other, float percent)
图像对比,返回true图像一致
·MonkeyImage other,对比MonkeyImage图像。 ·float percent,匹配百分比,范围为0.0~1.0,默认为1.0,即必须全部匹配。
compare=picture.sameAs(picture2,0.9)
4.
string convertToBytes(string format)
转换格式
picstr=picture.convertToBytes('jpg')
转载请注明原文地址: https://ju.6miu.com/read-667513.html