Ads*_*Ads 4 android webview android-viewpager android-espresso
我有一个使用 ViewPager 的 Android 应用程序,视图寻呼机中的每个 Fragment 都有自己的 WebView。我能够编写测试用例来检查 ViewPager 上的导航。但是如何测试作为视图寻呼机的第一个子级的 webview 中的 div 是否断言提供的字符串?
onWebView().withElement(findElement(Locator.ID, "desgination")).
check(webMatches(getText(), containsString("Doctor")));
Run Code Online (Sandbox Code Playgroud)
这个扔
android.support.test.espresso.AmbiguousViewMatcherException: 'WebView with JS enabled' 匹配层次结构中的多个视图。问题视图在下方标有“****MATCHES****”。
将您的代码更改为
onWebView(Matchers.allOf(isDisplayed(), isJavascriptEnabled()))
.withElement(findElement(Locator.ID, "desgination"))
.check(webMatches(getText(), containsString("Doctor")));
Run Code Online (Sandbox Code Playgroud)
需要使用 isDisplayed() 方法来自动选择当前屏幕上的那个。
| 归档时间: |
|
| 查看次数: |
2884 次 |
| 最近记录: |