我有一个非常基本的脚本,我打算让应用程序拖动 3 次,然后触摸一个按钮。该应用程序完美地拖动了三遍,但是当我添加触摸代码时出现错误。
代码:
device, serialno = ViewClient.connectToDeviceOrExit())
device.drag((120, 220), (300, 220), 1, 20)
MonkeyRunner.sleep(5)
device.drag((120, 220), (300, 220), 1, 20)
MonkeyRunner.sleep(3)
device.drag((120, 220), (300, 220), 1, 20)
temp = device.findViewWithText('Lesson 1')
temp.touch()
错误:
line 34, in <module>
device, serialno = ViewClient(*ViewClient.connectToDeviceOrExit())
TypeError: 'instance' object is not iterable
新代码:
device, serialno = ViewClient.connectToDeviceOrExit()
temp = device.findViewWithText('Lesson')
新错误:
temp = device.findViewWithText('Audiobooks')
AttributeError: 'com.android.monkeyrunner.MonkeyDevice' object has no attribute 'findViewWithText'