Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Automation 无法单击“删除”按钮,多视图_Automation_Ui Automation_Android Espresso_Android Espresso Recorder - Fatal编程技术网

Automation 无法单击“删除”按钮,多视图

Automation 无法单击“删除”按钮,多视图,automation,ui-automation,android-espresso,android-espresso-recorder,Automation,Ui Automation,Android Espresso,Android Espresso Recorder,Unabel单击“删除”按钮,出现错误: android.support.test.espresso.AmbiguousViewMatcherException: '(with id: cit:id/delete_button and has parent matching: with id: cit:id/count_and_delete and is displayed on the screen to the user)' matches multiple views in the hie

Unabel单击“删除”按钮,出现错误:

android.support.test.espresso.AmbiguousViewMatcherException: '(with id: cit:id/delete_button and has parent matching: with id: cit:id/count_and_delete and is displayed on the screen to the user)' matches multiple views in the hierarchy.
我正在使用以下代码单击删除图标:

ViewInteraction appCompatImageView222 = onView(
                allOf(withId(R.id.delete_button),
                        withParent(withId(R.id.count_and_delete)),
                        isDisplayed()));
        appCompatImageView222.perform(actionOnItemAtPosition(0, click()));


ViewInteraction appCompatImageView222 = onView(
                    allOf(withId(R.id.delete_button),
                            withParent(withId(R.id.count_and_delete)),
                            isDisplayed()));
            appCompatImageView222.perform(click());
您的matcher AllowWithidR.id.delete_按钮,以及ParentWithidR.id.count_和_delete,IsDisplay仍然不够唯一,因为它仍然在屏幕上找到两个视图匹配器。相反,请尝试与其父视图中的文本匹配:

onView(allOf(
        withId(R.id.delete_button),
        withParent(withParent(withChild(withText("Count 1"))))))
                .check(matches(isDisplayed()))
                .perform(click())