Issue
Following is the snapshot of my AutoCompleteTextView dropdown, from which I'm trying to select 2nd item
My Espresso Code:
onView(withId(R.id.searchContainer)).check(matches(isDisplayed()));
onData(anything())
.inAdapterView(withId(R.id.searchContainer))
.atPosition(1)
.perform(click());
But I'm getting following Exception:
android.support.test.espresso.PerformException: Error performing 'load adapter data' on view 'with id: com.sampleaddressdd.demo:id/searchContainer'
With Espresso Recorder I get following code:
DataInteraction appCompatTextView = onData(anything())
.inAdapterView(childAtPosition(
withClassName(is("android.widget.PopupWindow$PopupBackgroundView")),
0))
.atPosition(0);
appCompatTextView.perform(click());
Dropdown inflater code :
mSearchView = findViewById(R.id.textSearch);
mSearchView.setDropDownAnchor(R.id.searchContainer);
mHttpClient.fetchAddresss(new HttpClient.AddressCallback() {
@Override
public void run() {
mAdapter = new AddressAdapter(MainActivity.this, mAddresss, new AddressAdapter.OnAddressClickCallback() {
@Override
public void execute(Address Address) {
startActivity(AddressProfileActivity.createIntent(MainActivity.this, Address));
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
mSearchView.setAdapter(mAdapter);
}
});
}
});
Solution
Finally Achieved this with the use of :
onView(withText(LOCATION_TO_BE_SEARCHED)) .inRoot(withDecorView(not(mActivityTestRule.getActivity().getWindow().getDecorView()))) .check(matches(isDisplayed())) .perform(click());
Answered By - Kushal Bhalaik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.