Created
February 22, 2020 18:40
-
-
Save testableapple/792a556e8cff52faddc8d8298949401f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun ViewInteraction.isDisplayed(): Boolean { | |
| try { | |
| this.check(ViewAssertions.matches(ViewMatchers.isDisplayed())) | |
| } catch (ignored: NoMatchingViewException) { | |
| return false | |
| } | |
| return true | |
| } | |
| fun ViewInteraction.doesNotExist(): Boolean { | |
| try { | |
| this.check(ViewAssertions.doesNotExist()) | |
| } catch (ignored: AssertionError) { | |
| return false | |
| } | |
| return true | |
| } | |
| fun ViewInteraction.waitForAppear(millis: Long = 5000): ViewInteraction { | |
| val timeout = System.currentTimeMillis() + millis | |
| while (System.currentTimeMillis() < timeout) { | |
| if (this.isDisplayed()) { break } | |
| } | |
| return this | |
| } | |
| fun ViewInteraction.waitForDisappear(millis: Long = 5000): ViewInteraction { | |
| val timeout = System.currentTimeMillis() + millis | |
| while (System.currentTimeMillis() < timeout) { | |
| if (this.doesNotExist()) { break } | |
| } | |
| return this | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment