Open tarkikmittal opened 8 years ago
I just had the same issue. I was able to resolve it using this matcher:
onView(allOf(withParent(withId(R.id.fab)), withClassName(endsWith("ImageView")), isDisplayed()))
.perform(click());
The Problem is that the FloatingActionMenu
is a ViewGroup which is inflating the FloatingActionButton as child of the view with the fab id.
Thanks @DreierF. I'm using that as well and it works great.
I'm using this third party floating action button "com.github.ag.floatingactionmenu.OptionsFabLayout". In this case, how can i click on the floating action button ?
I am writing a UI automation test case using Google Expresso UI testing framework. I have added id and contentDescription to but still not able to perform click on floating button.
my code as below
layout.xml <com.github.clans.fab.FloatingActionMenu android:id="@+id/fltBtn" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" fab:menu_animationDelayPerItem="20" android:contentDescription="@string/floating_button" fab:menu_backgroundColor="#bbcccccc" />
test.java
onView(withId(R.id.fltBtn)).check(matches(isDisplayed())); onView(withId(R.id.fltBtn)).perform(click());
onView(withContentDescription(R.string.floating_button)).perform(click());
both commands are not working. can you please suggest what will enable UI testing of these components. as same is working in default floating button provided by android