问题描述
我想测试我的形式是NestedScrollView内EditTexts。我正在下面code:
I am trying to test EditTexts in my form that are within a NestedScrollView. I am running the following code:
onView(withId(R.id.register_scroll_view)).perform(scrollTo()).perform(click());
其中 register_scroll_view 是我NestedScrollView。不过,我得到一个例外:
where register_scroll_view is my NestedScrollView. However, I am getting an exception:
android.support.test.es presso.PerformException:错误执行滚动到对视图'id为:com.eazyigz.myapp:ID / register_scroll_view。
了java.lang.RuntimeException:通过引起动作将不会执行,因为目标视图不匹配的下面的约束的一个或多个:
(视图具有有效可视性=可见的,是的后裔:(是从类分配:类android.widget.ScrollView或者是从类分配:类android.widget.HorizontalScrollView))
不过,我怎么正确地设计这个测试,这样我可以测试我的EditTexts这就需要滚动到成为可见?
However, how do I properly devise this test so that I can test my EditTexts which need to be scrolled to to become visible?
推荐答案
我没有与任何NestedScrollView经验,但现在看来, requestRectangleOnScreen()
,这是如何ES在常规的滚动型preSSO卷轴,应与NestedScrollView工作一样。
I don't have any experience with NestedScrollView, but it appears that requestRectangleOnScreen()
, which is how espresso scrolls in the regular ScrollView, should work with NestedScrollView just the same.
唯一的问题是,滚动型约束是很难coded到 scrollTo()
行动,NestedScrollView不会继承定期滚动型。
The only problem is that ScrollView constrain is hardcoded into the scrollTo()
action and NestedScrollView doesn't inherit the regular ScrollView.
我相信这里唯一的解决办法是复制并粘贴整个<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/5.0.2_r1/com/google/android/apps/common/testing/ui/es$p$psso/action/ScrollToAction.java\"相对=nofollow> ScrollToAction 类到自己实施这一行动,并更换讨厌约束。
I believe the only solution here is to copy and paste entire ScrollToAction class into your own implementation of this action and replace the pesky constrain.
这篇关于ES preSSO NestedScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!