I am trying to search a video in youtube using AndroidViewClient.
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')
The line :
search = vc.findViewWithTextOrRaise(re.compile(u'Search\ YouTube'))
Throws a view not found error even though there is a view with the exact text.
It works if i dump the window:
vc.dump(window='-1')
search = vc.findViewWithTextOrRaise(re.compile(u'Search\ YouTube'))
Can anyone tell me why this is necessary? How do i recognize that i have to dump the window before finding a view, any tips?