gpt4 book ai didi

android - Espresso 嵌套 ScrollView

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:58:08 25 4
gpt4 key购买 nike

我正在尝试在 NestedScrollView 中测试表单中的 EditText。我正在运行以下代码:

onView(withId(R.id.register_scroll_view)).perform(scrollTo()).perform(click());

register_scroll_view 是我的 NestedScrollView。但是,我遇到了一个异常(exception):

android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: com.eazyigz.myapp:id/register_scroll_view'. Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints: (view has effective visibility=VISIBLE and is descendant of a: (is assignable from class: class android.widget.ScrollView or is assignable from class: class android.widget.HorizontalScrollView))

如何正确设计此测试,以便我可以测试需要滚动到可见的 EditText?

最佳答案

我没有任何使用 NestedScrollView 的经验,但看起来 requestRectangleOnScreen()( Espresso 在常规 ScrollView 中的滚动方式)应该与 NestedScrollView 一样工作。

唯一的问题是 ScrollView 约束被硬编码到 scrollTo() 操作中,而 NestedScrollView 不继承常规 ScrollView。

我相信这里唯一的解决方案是复制并粘贴整个 ScrollToAction类到您自己的此操作的实现中并替换讨厌的约束。

关于android - Espresso 嵌套 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31614937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com