Issue
On Activity A, I click on a button and call Activity B. And then I matches if addressNickNameView from Activity B is the same on itemAddressNickNameView
onView(withId(R.id.addressNickNameView))
.check(matches(withId(R.id.itemAddressNickNameView)))`
But I facing this problem.
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'with id: 2131363004' doesn't match the selected view. Expected: with id: br.com.fastshop.ecommerce.mock.teste:id/itemAddressNickNameView Got: "TextInputEditText{id=2131362631, res-name=component_fast_edittext_edit_text_cpf, visibility=VISIBLE, width=998, height=72, has-focus=false ....
Solution
I don't think the Matcher is able to work like that across activities. You need to capture the value from the first activity before going to the second activity, something like:
@Rule
public ActivityTestRule<ActivityA> mActivityTestRule = new ActivityTestRule<>(ActivityA.class);
@Test
public void test() {
EditText editTextA = mActivityTestRule.getActivity().findViewById(R.id.itemAddressNickNameView);
String textA = editTextA.getText().toString();
// Move to Activity B
onView(R.id.button).perform(click());
onView(withId(R.id.addressNickNameView)).check(matches(withText(textA)));
}
Answered By - Maya McKela
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.