Espresso Webview选择隐藏元素 [英] Espresso Webview select hidden element
问题描述
如何使用espresso在Android Webview中找到隐藏的元素?这是我尝试过的:
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:错误 评价评价:状态:13值:{message =无效或非法 指定了选择器} hasMessage:正确的消息:无效或 在指定了非法选择器 android.support.test.espresso.web.sugar.Web $ WebInteraction $ ExceptionPropagator.(Web.java:323) 在 android.support.test.espresso.web.sugar.Web $ WebInteraction.doEval(Web.java:292) 在 android.support.test.espresso.web.sugar.Web $ WebInteraction.withElement(Web.java:208) 在 com.middlestump.MainActivityInstrumentationTest.createAlert(MainActivityInstrumentationTest.java:89) 在java.lang.reflect.Method.invoke(本机方法)在 java.lang.reflect.Method.invoke(Method.java:372)在 org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:50)
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)
MainActivityInstrumentationTest.java:89位是我给出的代码行.
The MainActivityInstrumentationTest.java:89 bit is the line of code I have given.
也尝试过:
onWebView().withElement(findElement(Locator.CSS_SELECTOR, "#clsp")).check(isDisplayed());
但是WebAssertion
和ViewAssertion
推荐答案
滑动网页视图并找到隐藏的元素:
Swipe webview and find the hidden element:
onView(withId(R.id.webView)).perform(ViewActions.swipeUp());
这篇关于Espresso Webview选择隐藏元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!