因此,我正在尝试自动化 Security > Screen Lock > None 选项,但我似乎在让 AndroidViewClient “选择”屏幕锁定选项时遇到了一些麻烦,该选项会将您带到下一个菜单以选择您的屏幕。这是代码:
device, serialno = ViewClient.connectToDeviceOrExit(serialno=devices[input])
print("Modifying settings...")
device.startActivity(settings_uri)
vc = ViewClient(device, serialno)
# Disable screen lock
vc.findViewWithTextOrRaise("Security").getParent().getParent().touch()
MonkeyRunner.sleep(3)
vc.findViewWithTextOrRaise(re.compile('Screen lock')).touch()
这会导致以下异常:
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/home/allen/projects/cts-scripts/4.2/cts-setup.py", line 585, in <module>
main()
File "/home/allen/projects/cts-scripts/4.2/cts-setup.py", line 550, in main
vc.findViewWithTextOrRaise(re.compile('Screen lock')).touch()
File "/home/allen/projects/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/viewclient.py", line 2052, in findViewWithTextOrRaise
raise ViewNotFoundException("text", text, root)
com.dtmilano.android.viewclient.ViewNotFoundException: Couldn't find View with text that matches 'Screen lock' in tree with root=ROOT
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Throwable.<init>(Throwable.java:181)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Exception.<init>(Exception.java:29)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.RuntimeException.<init>(RuntimeException.java:32)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.<init>(PyException.java:46)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.doRaise(PyException.java:219)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.makeException(Py.java:1239)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.makeException(Py.java:1243)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.makeException(Py.java:1247)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.findViewWithTextOrRaise$97(/home/allen/projects/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/viewclient.py:2052)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.call_function(/home/allen/projects/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/viewclient.py)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:141)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.__call__(PyFunction.java:327)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.__call__(PyMethod.java:124)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.main$48(/home/allen/projects/cts-scripts/4.2/cts-setup.py:550)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(/home/allen/projects/cts-scripts/4.2/cts-setup.py)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:120)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.__call__(PyFunction.java:307)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.f$0(/home/allen/projects/cts-scripts/4.2/cts-setup.py:585)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(/home/allen/projects/cts-scripts/4.2/cts-setup.py)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.runCode(Py.java:1275)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.__builtin__.execfile_flags(__builtin__.java:522)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:225)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
130614 18:09:43.547:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
关于问题是什么的任何想法?