【问题标题】:Espresso - Assert the text twice with same index valueEspresso - 使用相同的索引值两次断言文本
【发布时间】:2021-07-27 04:54:50
【问题描述】:

在屏幕中,我有两次“可用”文本。 两者都有索引值 1

设备存储:

 Available

SD 卡

Available

我如何断言这两个“可用”文本

【问题讨论】:

  • 你现在用什么测试?
  • onView(withText(containsString("Available"))).check(matches(isDisplayed()));像这样我试图断言。但我需要检查在设备存储和 SD 卡下是否看到文本“可用”。 @RishabhDeepSingh

标签: android android-studio android-espresso assertion


【解决方案1】:

您可以使用也引用同级视图的 ViewMatcher。

onView(allOf(withText(containsString("Available")), hasSibling(withText("Device Storage"))).check(matches(isDisplayed()))

onView(allOf(withText(containsString("Available")), hasSibling(withText("SD Card"))).check(matches(isDisplayed()))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    • 2015-07-02
    • 2018-08-31
    相关资源
    最近更新 更多