在活动A上,我单击一个按钮并调用活动B。然后我匹配活动B中的addressNickNameView是否与项目addressNickNameView 相同
onView(withId(R.id.addressNickNameView))
.check(matches(withId(R.id.itemAddressNickNameView)))`
但我面临着这个问题。
android.support.test.sespress.base.DefaultFailureHandler$AssertionFailedWithCauseError:"id为2131363004"与所选视图不匹配。应为:id为:br.com.fastshop.ecommerce.mock.teste:id/itemAddressNickNameView得到:"TextInputEditText{id=2131362631,res name=component_fast_edittext_edit_text_cpf,visibility=VISIBLE,width=998,height=72,has focus=false…
我不认为Matcher能够在活动中像这样工作。在进入第二个活动之前,您需要捕获第一个活动的值,例如:
@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)));
}