尝试使用浓咖啡测试我的登录。如果我点击我的领域,那么所有的工作都很好。TypeText无法使用
ViewInteraction linearLayout = onView(
allOf(childAtPosition(
allOf(withId(R.id.nameEditText),
childAtPosition(
withId(R.id.inputLayout),
0)),
0),
isDisplayed()));
linearLayout.check(matches(isDisplayed()))
.perform(click());
但是,如果我需要把一些文字在这个领域,我有一些问题:
ViewInteraction linearLayout = onView(
allOf(childAtPosition(
allOf(withId(R.id.nameEditText),
childAtPosition(
withId(R.id.inputLayout),
0)),
0),
isDisplayed()));
linearLayout.check(matches(isDisplayed()))
.perform(typeText("SomeName"));
并获得下一个错误:
android.support.test.espresso.PerformException: Error performing 'type text(SomeName)' on view '(Child at position 0 in parent (with id: com.fentury.android:id/nameEditText and Child at position 0 in parent with id: com.fentury.android:id/inputLayout)
OR
如果我尝试这样做:
ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.nameEditText),
withParent(withId(R.id.inputLayout)), isDisplayed()));
appCompatEditText.check(matches(isDisplayed()))
.perform(click()).perform(typeText("Dog"));
我已经凌海了同样的错误:
android.support.test.espresso.PerformException: Error performing 'type text(Dog)' on view '(with id: com.fentury.android:id/nameEditText and has parent matching: with id: com.fentury.android:id/inputLayout and is displayed on the screen to the user)'
我如何解决这个错误?
你能提供你的布局吗?如果您将其命名为正确,linearLayout将无法输入文本。 – quanlt