【问题标题】:Testing autocomplete textview using espresso tool使用 espresso 工具测试自动完成文本视图
【发布时间】:2016-03-29 12:42:06
【问题描述】:

我有一个自动完成的文本视图,我在它上面设置了一个适配器视图来显示建议列表。在对浓缩咖啡进行测试时,我想从建议列表中选择一个项目位置,但是它不能识别浓缩咖啡上的自动完整文本视图适配器。

我从堆栈溢出中尝试了这个答案: DropDown value selection using espresso android with dynamic element id's

但是,这对我不起作用。对此的任何帮助都会很棒。 谢谢。

【问题讨论】:

    标签: android-arrayadapter autocompletetextview android-espresso


    【解决方案1】:

    或者你可以尝试onData。因为 onData 不适合我

     onView(withText("Your field name"))
    .inRoot(withDecorView(not(is(getActivity().getWindow().getDecorView()))))
                .perform(click());
    

    【讨论】:

    • 这似乎不再适用于带有 Espresso 3.1.1 的现代 Android 10
    【解决方案2】:

    我遇到了同样的问题,我就是这样做的:

    onView(withId(R.id.sp_country/*auto complete textview*/)).perform(click());
    onData(allOf(is(instanceOf(String.class)), is(COUNTRY/*selected value autocomplete collection*/)))
                    .inRoot(RootMatchers.withDecorView(not(is(activityActivityTestRule
                            .getActivity().getWindow().getDecorView()))))
                    .perform(click());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多