13

With Espresso I try to scroll to a textview inside linearlayout - but I am getting this exception:

android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: 

org.ligi.gobandroid_hd:id/final_points'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
at reporting.SpooningFailureHandler.handle(SpooningFailureHandler.java:31)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at org.ligi.gobandroidhd.uitest.TheGameScoringActivity.testThatTapToMarkWorks(TheGameScoringActivity.java:65)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at junit.framework.TestResult.runProtected(TestResult.java:133)
at android.support.test.internal.runner.junit3.DelegatingTestResult.runProtected(DelegatingTestResult.java:90)
at junit.framework.TestResult.run(TestResult.java:118)
at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:49)
at junit.framework.TestCase.run(TestCase.java:124)
at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)
at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:63)
at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)
Caused by: java.lang.RuntimeException: Scrolling to view was attempted, but the view is not displayed
at android.support.test.espresso.action.ScrollToAction.perform(ScrollToAction.java:66)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Manually I can scroll to this view.

ligi
  • 39,001
  • 44
  • 144
  • 244
  • If the keyboard is displayed it can also cause the error since the view that is scrolled to is not visible to the user. For example, after performing `editText()` the keyboard will be visible. – hexicle Dec 01 '17 at 13:09

1 Answers1

21

The problem appears when the ScrollView has a padding - gave it to the layout inside the ScrollView and everything works fine. Maybe a bug in the calculation of coordinates.

For example:

code change

Jing Li
  • 14,547
  • 7
  • 57
  • 69
ligi
  • 39,001
  • 44
  • 144
  • 244
  • 2
    It also appears when the scrollview doesn't have it :·( It happens with this non-padded ScrollView: https://gist.github.com/rocboronat/a00a76c4af63d23495b6a1237ef6113b – Roc Boronat Jan 04 '17 at 12:32
  • @ligi How to resolve this issue? can you share sample code? – anuja jain May 15 '17 at 07:36
  • You are the man! Thank you so much. I spent a whole day around this bug and now I only had to remove a paddingBottom from the parent ScrollView and put it on the child LinearLayout. Again, many thanks!!! – luiscosta Mar 05 '20 at 11:08