Android 要在windows平台上运行Monkeyrunner以加载图像进行比较吗 checking=MonkeyRunner.loadImageFromFile(chk) checking=MonkeyRunner.loadFromFile(chk) checking=MonkeyImage.loadFromFile(chk)

Android 要在windows平台上运行Monkeyrunner以加载图像进行比较吗 checking=MonkeyRunner.loadImageFromFile(chk) checking=MonkeyRunner.loadFromFile(chk) checking=MonkeyImage.loadFromFile(chk),android,monkeyrunner,Android,Monkeyrunner,所有这些都是错误的 回溯(最近一次呼叫最后一次): 文件“stdin”,第1行,在 AttributeError:类型对象“com.android.monkeyrunner.monkeyrunner”没有属性 但是“loadFromFile” 要查看monkeyrunner中的内容,请运行以下脚本: #! /opt/android-sdk/tools/monkeyrunner from com.android.monkeyrunner import MonkeyRunner, MonkeyDe

所有这些都是错误的

回溯(最近一次呼叫最后一次): 文件“stdin”,第1行,在 AttributeError:类型对象“com.android.monkeyrunner.monkeyrunner”没有属性 但是“loadFromFile”


要查看monkeyrunner中的内容,请运行以下脚本:

#! /opt/android-sdk/tools/monkeyrunner

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage

for m in [MonkeyRunner, MonkeyDevice, MonkeyImage]:
    print "%s:\n   %s\n" % (m.__name__, dir(m))
您将看到定义的内容和位置。例如,SDK中的monkeyrunner返回

MonkeyRunner:
   ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'alert', 'choice', 'help', 'input', 'sleep', 'waitForConnection']

MonkeyDevice:
   ['DOWN', 'DOWN_AND_UP', 'UP', '__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'broadcastIntent', 'drag', 'getProperty', 'getSystemProperty', 'installPackage', 'instrument', 'press', 'reboot', 'removePackage', 'shell', 'startActivity', 'takeSnapshot', 'touch', 'type', 'wake']

MonkeyImage:
   ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'convertToBytes', 'getRawPixel', 'getRawPixelInt', 'getSubImage', 'sameAs', 'writeToFile']

如果不是您所期望的,请从源代码构建。

要查看monkeyrunner中的内容,请运行以下脚本:

#! /opt/android-sdk/tools/monkeyrunner

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage

for m in [MonkeyRunner, MonkeyDevice, MonkeyImage]:
    print "%s:\n   %s\n" % (m.__name__, dir(m))
您将看到定义的内容和位置。例如,SDK中的monkeyrunner返回

MonkeyRunner:
   ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'alert', 'choice', 'help', 'input', 'sleep', 'waitForConnection']

MonkeyDevice:
   ['DOWN', 'DOWN_AND_UP', 'UP', '__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'broadcastIntent', 'drag', 'getProperty', 'getSystemProperty', 'installPackage', 'instrument', 'press', 'reboot', 'removePackage', 'shell', 'startActivity', 'takeSnapshot', 'touch', 'type', 'wake']

MonkeyImage:
   ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'convertToBytes', 'getRawPixel', 'getRawPixelInt', 'getSubImage', 'sameAs', 'writeToFile']

如果不是您所期望的,则从源代码构建。

我宁愿使用python的PIL库来完成这项工作。
您必须单独安装PIL

将此操作分为两部分。 首先拍摄当前图像

使用PIL库编写python脚本,如下所示

from PIL import Image
from PIL import ImageChops

def equal(im1, im2):
    return ImageChops.difference(im1, im2).getbbox() is None

im1 = Image.open("current.png")
im2 = Image.open("reference.jpg")
equal(im1, im2)
注意:必须安装python和PIL库才能工作。

此功能检查两个图像之间的差异。
current.png是从设备捕获的,reference.png是参考图像。
在单独的文件中编写此代码,并从monkeyrunner脚本调用


p.S.如果您无法破解monkeyrunner代码,或者monkeyrunner在以后的版本中没有提供此功能,请使用它。

我宁愿使用python的PIL库来完成此工作。
您必须单独安装PIL

将此操作分为两部分。 首先拍摄当前图像

使用PIL库编写python脚本,如下所示

from PIL import Image
from PIL import ImageChops

def equal(im1, im2):
    return ImageChops.difference(im1, im2).getbbox() is None

im1 = Image.open("current.png")
im2 = Image.open("reference.jpg")
equal(im1, im2)
注意:必须安装python和PIL库才能工作。

此功能检查两个图像之间的差异。
current.png是从设备捕获的,reference.png是参考图像。
在单独的文件中编写此代码,并从monkeyrunner脚本调用


p.S.如果您无法破解monkeyrunner代码,或者monkeyrunner在以后的版本中没有提供此功能,请使用它。

使用Android SDK中最新的monkeyrunner(目前是)

MonkeyRunner模块中的使用方法:

MonkeyRunner.loadImageFromFile(imgFullPath)

使用Android SDK中最新的Monkeyrunner(目前为)

MonkeyRunner模块中的使用方法:

MonkeyRunner.loadImageFromFile(imgFullPath)

米拉诺。我和预期的一样。但我的问题是升级monkeyrunner。请告诉我最新monkeyrunner.dtmilano的详细信息。我和预期的一样。但我的问题是升级monkeyrunner。请告诉我最新monkeyrunner的详细信息。你是如何在monkeyrunner中获得PIL的?你是如何在monkeyrunner中获得PIL的?