monkeyrunner不能同时操作两个设备的疑问
数据猴赛雷 2013-09-07 06:08:46 一、网上说monkeyrunner可以通过不同的设备名控制多个设备,具体的方法为:
device1 = MonkeyRunner.waitForConnection(1,"emulator-5554")
device2 = MonkeyRunner.waitForConnection(1,"0123456789ABCDEF")
就可以控制多台设备或者虚拟机。
二、但是我自己写了下代码,发现只能操作一个设备,我的代码如下:
# -*- coding: utf-8 -*-
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By
def main():
device1 = MonkeyRunner.waitForConnection('1123456789ABCDEF')
if not device1:
print("device1 connection fail")
else:
print("device1 connection success")
device2 = MonkeyRunner.waitForConnection('0123456789ABCDEF')
if not device2:
print("device2 connection fail")
else:
print("device2 connection success")
if __name__ == "__main__":
main()
最后的结果是:
第一行显示device1 connection success,第二行指针在跳动(处于等待状态)。
我不知道为什么我就不能同时控制两台设备。
请哪位大牛能否解答一下,多谢。
附加说明:(1)通过输入adb devices命令可以发现有两个设备名,分别是1123456789ABCDEF和0123456789ABCDEF。
(2)我如果把device1 = MonkeyRunner.waitForConnection('1123456789ABCDEF')注释掉,就会显示device2 connection success