How does Expresso generate View Hierarchy when performing actions?

1,000 views
Skip to first unread message

pezh...@gmail.com

unread,
Apr 10, 2017, 4:19:35 PM4/10/17
to Android Testing Support Library
Hi,

I'd like to dynamically decide what views to click. So I did this 


View decor = getActivity().getWindows().getView()
ArrayList<View> views = new ArrayList<>();
for (View v : TreeIterables.breadthFirstViewTraversal(decor)) {
    views.add(v);
}

But after I printed out the views array, it is actually a different view hierarchy as Espresso generates.

This is especially true when a dialog pops up, Espresso will be able to find the correct view hierarchy however my way fails.

Any idea?

spangebo...@gmail.com

unread,
Apr 14, 2017, 1:49:24 AM4/14/17
to Android Testing Support Library, pezh...@gmail.com
Any ideas? same issue here

Luis Ramirez

unread,
Apr 14, 2017, 12:57:12 PM4/14/17
to spangebo...@gmail.com, Android Testing Support Library, pezh...@gmail.com
Could you guys elaborate a bit on what you're trying to do and what you're asking? I, for one, am not clear on what you're getting at here. Like "I'd like to dynamically decide what views to click." What does that mean and why do you need this?

--
You received this message because you are subscribed to the Google Groups "Android Testing Support Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-testing-suppo...@googlegroups.com.
To post to this group, send email to android-testing...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-testing-support-library/1be24128-7e2a-46fb-b049-deae71abf567%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pezh...@gmail.com

unread,
Apr 15, 2017, 8:52:47 PM4/15/17
to Android Testing Support Library, spangebo...@gmail.com, pezh...@gmail.com
When espresso cannot find a matching view, it generates this kind of errors:
Espresso no matching view exception: android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with content description: is "Highscore, Open navigation drawer"
                                                                             If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:com.android.internal.view.menu.ExpandedMenuView{3450462 VFED.VC.. .F...... 12,12-387,84 #102032a android:id/expanded_menu}
                                                                             
                                                                             View Hierarchy:
                                                                             +>DecorView{id=-1, visibility=VISIBLE, width=399, height=84, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} 
                                                                             |
                                                                             +->ExpandedMenuView{id=16909098, res-name=expanded_menu, visibility=VISIBLE, width=375, height=72, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=12.0, y=12.0, child-count=1} 
                                                                             |

I just want to know how to generate the View Hierarchy




On Friday, April 14, 2017 at 10:57:12 AM UTC-6, Luis Ramirez wrote:
Could you guys elaborate a bit on what you're trying to do and what you're asking? I, for one, am not clear on what you're getting at here. Like "I'd like to dynamically decide what views to click." What does that mean and why do you need this?

On Fri, Apr 14, 2017 at 12:49 AM <spangebo...@gmail.com> wrote:
Any ideas? same issue here


On Monday, April 10, 2017 at 2:19:35 PM UTC-6, pezh...@gmail.com wrote:
Hi,

I'd like to dynamically decide what views to click. So I did this 


View decor = getActivity().getWindows().getView()
ArrayList<View> views = new ArrayList<>();
for (View v : TreeIterables.breadthFirstViewTraversal(decor)) {
    views.add(v);
}

But after I printed out the views array, it is actually a different view hierarchy as Espresso generates.

This is especially true when a dialog pops up, Espresso will be able to find the correct view hierarchy however my way fails.

Any idea?

--
You received this message because you are subscribed to the Google Groups "Android Testing Support Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-testing-support-library+unsubscribe@googlegroups.com.
To post to this group, send email to android-testing-support-lib...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages