I have an Android Application that uses ViewPager and each Fragment in the view pager has its own WebView. I am able to write test case to check navigation on the ViewPager. But how can I test whether the div in the webview which is first child of the view pager asserts the provided string?
onWebView().withElement(findElement(Locator.ID, "desgination")).
check(webMatches(getText(), containsString("Doctor")));
This one throws
android.support.test.espresso.AmbiguousViewMatcherException: 'WebView with JS enabled' matches multiple views in the hierarchy. Problem views are marked with '****MATCHES****' below.
Change your code to
onWebView(Matchers.allOf(isDisplayed(), isJavascriptEnabled()))
.withElement(findElement(Locator.ID, "desgination"))
.check(webMatches(getText(), containsString("Doctor")));
The isDisplayed() method is needed to automatic select the one that is currently on your screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With