我有多个设备与系统连接,并且只想在特定设备上运行脚本,该设备的序列号将由另一个 python 脚本返回。我在猴子运行脚本中导入了该类,但它引发了错误 - "No module named Device"
。我可以看到开发人员过去面临类似的问题,但没有找到解决问题的任何解决方案。从最近几天开始,我一直被这个问题困扰,感谢您的帮助。谢谢。
代码:
#! /usr/bin/env monkeyrunner
from com.android.monkeyrunner import MonkeyRunner
from random import randint
import time
from device import Device
try:
device = MonkeyRunner.waitForConnection(5, device.getDeviceSerial)
print("Device Connection Established")
except Exception:
print("Device Connection Not Established")
.....
执行 monkeyrunner 命令后 -monkeyrunner runtest
抛出的错误是:
No module named Device
Device.py编写了一个逻辑来返回必须执行测试的正确设备序列。