如何使用espresso按setPositiveButton类型的AlertDialog按钮

时间:2017-06-08 09:32:20

标签: android android-espresso

如果我想按ADD按钮,我试过:

onView(withText("ADD")).perform(click())

以及

onView(withText("ADD"))
                .inRoot(isDialog()) 
                .check(matches(isDisplayed()))
                .perform(click());

但它们都不起作用well

2 个答案:

答案 0 :(得分:0)

我会建议您在这种情况下使用Error in library("quantmod", lib.loc = "/tmp/RtmpwSKGIl/downloaded_packages") : there is no package called ‘quantmod’ ,更多info

尝试这样做

uiautomator

答案 1 :(得分:0)

Espresso withText()区分大小写。您正在检查测试中的“ADD”,但在对话框的构造中将值设置为“添加”。如果'ADD'在您的UI中以可视方式显示,则可能是由于textView上设置了样式或textallcaps,但Espresso实际上是在寻找窗口小部件上设置的基础文本值。