AndroidViewClient和系统设置应用
作者:互联网
所以我正在尝试自动化安全>屏幕锁定>没有选项,但我似乎在让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)
关于问题是什么的任何想法?
解决方法:
我弄清楚问题是什么.每次屏幕上的内容发生变化时,您都必须调用vc.dump().
标签:android,automation,monkeyrunner,androidviewclient 来源: https://codeday.me/bug/20190831/1778538.html