import sys
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
device = MonkeyRunner.waitForConnection()
devWidth = int(device.getProperty('display.width'))
devHeight = int(device.getProperty('display.height'))
或者代码如下:
import sys
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
device = MonkeyRunner.waitForConnection()
devWidth = device.getProperty('display.width')
devHeight = device.getProperty('display.height')
print devWidth,devHeight
出现错误如下:
120807 15:34:03.596:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Scri
pt terminated due to an exception
120807 15:34:03.596:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Looku
pError: no codec search functions registered: can't find encoding
120807 15:34:03.596:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
120807 15:34:03.596:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at java.lang.Throwable.<init>(Throwable.java:181)
120807 15:34:03.596:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at java.lang.Exception.<init>(Exception.java:29)
120807 15:34:03.596:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
经过查看发现是编码的错误,于是把这一行#-*- coding:utf-8 -*-去掉,重新运行,就Ok了。