android – Snackbar和Espresso有时会失败

android – Snackbar和Espresso有时会失败,第1张

概述正如标题所说,它失败了一些,有些则失败了. android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is displayed on the screen to the user' doesn't match the selected view.Expected: is di 正如标题所说,它失败了一些,有些则失败了.
androID.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is displayed on the screen to the user' doesn't match the selected vIEw.Expected: is displayed on the screen to the userGot: "AppCompatTextVIEw{ID=2131492981,res-name=snackbar_text,visibility=VISIBLE,wIDth=444,height=71,has-focus=false,has-focusable=false,has-window-focus=true,is-clickable=false,is-enabled=true,is-focused=false,is-focusable=false,is-layout-requested=false,is-selected=false,root-is-layout-requested=false,has-input-connection=false,x=18.0,y=0.0,text=Network Error,input-type=0,ime-target=false,has-links=false}"

堆栈跟踪的第一行表明espresso无法在屏幕上看到Snackbar.但第二行说明它实际上是看到一个Snackbar,其可见性= VISIBLE,而text = Network Error是正确的.

我很困惑,发生了什么事?

这是我的测试代码:

activityRule.launchActivity(new Intent());onVIEw(withText("Network Error")).check(matches(isdisplayed()));

PS:当我运行整套测试服时,它大多失败了;但有时当我单独运行此测试时它也会失败.有时它会传递绿色,但没有任何模式,似乎是随机的.

解决方法 晚了!但我希望它对其他人有帮助:

Testing Snackbar show with Espresso

private voID checkSnackbardisplayedByMessage(@StringRes int message) {    onVIEw(withText(message))        .check(matches(withEffectiveVisibility(            VIEwMatchers.Visibility.VISIBLE    )));}
总结

以上是内存溢出为你收集整理的android – Snackbar和Espresso有时会失败全部内容,希望文章能够帮你解决android – Snackbar和Espresso有时会失败所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1130553.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存