本文介绍了居preSSO:如果认为存在返回布尔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图检查,看是否有视图与长者preSSO。下面是一些伪code显示什么我想:

I am trying to check to see if a view is displayed with Espresso. Here is some pseudo code to show what I am trying:

if (!Espresso.onView(withId(R.id.someID)).check(doesNotExist()){
   // then do something
 } else {
   // do nothing, or what have you
 }

但我的问题是。检查(doesNotExist())不返回布尔值。这只是一个断言。随着UiAutomator我能够只是做一些事情,像这样:

But my problem is .check(doesNotExist()) does not return boolean. It is just an assertion. With UiAutomator I was able to just do something like so:

 if (UiAutomator.getbyId(SomeId).exists){
      .....
   }

我发现了这一点; <一href="https://$c$c.google.com/p/android-test-kit/source/browse/es$p$psso/lib/src/main/java/com/google/android/apps/common/testing/ui/es$p$psso/assertion/ViewAssertions.java#42"相对=nofollow>查线46 。还没有找到如何使用它。

I found this; check line 46. Still can't find out how to use it.

推荐答案

我们需要这种功能,我结束了实施它如下:

We need that functionality and I ended up implementing it below:

https://github.com/marcosdiez/es$p$psso_clone

if(onView(withText("click OK to Continue")).exists()){
    doSomething();
} else {
   doSomethingElse();
}

我希望这是对您有用。

I hope it is useful for you.

这篇关于居preSSO:如果认为存在返回布尔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 22:18