【发布时间】:2017-04-25 07:20:00
【问题描述】:
我正在尝试使用 AndroidViewClient 在 youtube 中搜索视频。
package = 'com.google.android.youtube'
activity = 'com.google.android.apps.youtube.app.WatchWhileActivity'
component = package + "/" + activity
device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(component=component)
vc = ViewClient(device, serialno)
search = vc.findViewWithContentDescriptionOrRaise(
re.compile(u'''Search'''))
search.touch()
search = vc.findViewWithTextOrRaise(re.compile(u'Search\ YouTube'))
search.type('hello')
device.press('KEYCODE_ENTER')
行:
search = vc.findViewWithTextOrRaise(re.compile(u'Search\ YouTube'))
即使存在带有确切文本的视图,也会引发视图未找到错误。
如果我转储窗口,它会起作用:
vc.dump(window='-1')
search = vc.findViewWithTextOrRaise(re.compile(u'Search\ YouTube'))
谁能告诉我为什么这是必要的?我如何识别在找到视图之前必须转储窗口,有什么提示吗?
【问题讨论】: