I have issue with android espresso test. Test pass locally but fail on FTL. It's simple test
onView(allOf(withId(R.id.text_supercategory_name), withText("Air conditioners"))).
check(matches(withText("Air conditioners")));
this test pass locally. On FTL I have error:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with id: blablabla:id/text_product_verdict and with text: is "Air conditioners")
I’m not understand whay I see ID which not used in my test id/text_product_verdict
… and this ID from another activity …
Activity for test is correct
@Rule
public ActivityTestRule<HomeActivity> mActivityTestRule = new ActivityTestRule<>(HomeActivity.class);
I checked the video of the failed test on FTL and see a lot of notifications on emulator img from FTL
I decide that the problem was a sticky notification from Google Hangouts and try run my test with --no-auto-google-login
flag. But have the same results. With onView(withText("Air conditioners")).check(matches(isDisplayed()));
test pass on FTL.
Is anyone can help with with issue?
It happened to me as well. It seems Firebase Test Lab does not recognize the id at withId(R.id.text_supercategory_name)
in some devices. We can use res-name instead.
Check out the view hierarchy in the log and grab the res-name in there with onView(withResourceName("res-name")).perform(click());
// change res-name to buttonPanel, button3, button2, or button1
+---->ScrollView{id=16908757, res-name=buttonPanel, visibility=VISIBLE, width=1008, height=217, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=1507.0, child-count=1}
|
+----->ButtonBarLayout{id=-1, visibility=VISIBLE, width=1008, height=217, has-focus=false, 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=4}
|
+------>AppCompatButton{id=16908315, res-name=button3, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}
|
+------>Space{id=16909293, res-name=spacer, visibility=INVISIBLE, width=429, height=0, has-focus=false, has-focusable=false, 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=42.0, y=203.0}
|
+------>AppCompatButton{id=16908314, res-name=button2, visibility=VISIBLE, width=271, height=189, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=471.0, y=14.0, text=Cancel, input-type=0, ime-target=false, has-links=false}
|
+------>AppCompatButton{id=16908313, res-name=button1, visibility=VISIBLE, width=224, height=189, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=742.0, y=14.0, text=OK, input-type=0, ime-target=false, has-links=false}
I found this issue also when using espresso. Then I using Barista for espresso wrapper. It's helping me to choose using R.id.name or R.string.name or "name" as the selector. Here click example from their GitHub :
clickOn(R.id.button);
clickOn(R.string.button_text);
clickOn("Next");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With