我尝试使用espresso ui测试访问电容角web应用程序,但始终会得到以下错误:
androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: an instance of android.webkit.WebView and webView.getSettings().getJavaScriptEnabled() is <true>活动和webview是可访问的扔电容,但是我怎么能让浓缩咖啡知道,使用哪个网页呢?
测试源代码:
@RunWith(AndroidJUnit4.class)
@LargeTest
public class SimpleOnDeviceUITest {
@Rule
public ActivityScenarioRule<MainActivity> activityRule = new ActivityScenarioRule<>(MainActivity.class);
private <T extends Activity> T getActivity(ActivityScenarioRule<T> activityScenarioRule) {
AtomicReference<T> activityRef = new AtomicReference<>();
activityScenarioRule.getScenario().onActivity(activityRef::set);
return activityRef.get();
}
@Test
public void useAppContext() throws Exception {
MainActivity activity = getActivity(activityRule);
WebView webview = activity.getBridge().getWebView();
onWebView()
.withElement(findElement(Locator.TAG_NAME, "h1"))
...发布于 2022-08-05 12:35:24
在升级到电容@4并在调用onWebView()之前增加睡眠后,问题得到了解决。
https://stackoverflow.com/questions/72912028
复制相似问题