我创建了简单的 python 脚本来执行无限循环来测试我的 android 应用程序,但是它只成功运行一次并停止。
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection('66b6cc0e')
while True:
device.touch (300, 1750, 'DOWN_AND_UP')
MonkeyRunner.sleep(3)
device.touch(742, 1213, 'DOWN_AND_UP')
MonkeyRunner.sleep(10)
device.touch(554, 1613, 'DOWN_AND_UP')
MonkeyRunner.sleep(10)
# Push SEND MESSAGE
device.touch(300, 1750, 'DOWN_AND_UP')
MonkeyRunner.sleep(3)
device.touch(742, 1213, 'DOWN_AND_UP')
MonkeyRunner.sleep(10)
device.touch(554, 1613, 'DOWN_AND_UP')
MonkeyRunner.sleep(10)
最佳答案
您应该在 try
( https://docs.python.org/3/tutorial/errors.html ) 中包含每个命令。最好不要有一个 bare except(即一个包罗万象的 except),但您可以尝试使用它进行调试。
关于python - 虽然真正的 python 脚本应该无限循环但它只执行一次 - Monkeyrunner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40292135/