Espresso Webview select hidden element

我是研究僧i 提交于 2019-12-24 17:00:35

问题


How do you find a hidden element inside an Android Webview using espresso? This is what I tried:

onWebView().withElement(findElement(Locator.CSS_SELECTOR, "#clsp:hidden"));

That produces the following stacktrace.

java.lang.RuntimeException: java.lang.RuntimeException: Error in evaluationEvaluation: status: 13 value: {message=An invalid or illegal selector was specified} hasMessage: true message: An invalid or illegal selector was specified at android.support.test.espresso.web.sugar.Web$WebInteraction$ExceptionPropagator.(Web.java:323) at android.support.test.espresso.web.sugar.Web$WebInteraction.doEval(Web.java:292) at android.support.test.espresso.web.sugar.Web$WebInteraction.withElement(Web.java:208) at com.middlestump.MainActivityInstrumentationTest.createAlert(MainActivityInstrumentationTest.java:89) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

The MainActivityInstrumentationTest.java:89 bit is the line of code I have given.

Also tried:

onWebView().withElement(findElement(Locator.CSS_SELECTOR, "#clsp")).check(isDisplayed());

But there is a type mismatch between WebAssertion and ViewAssertion


回答1:


Swipe webview and find the hidden element:

onView(withId(R.id.webView)).perform(ViewActions.swipeUp());


来源:https://stackoverflow.com/questions/33662404/espresso-webview-select-hidden-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!