Skip to content

Instantly share code, notes, and snippets.

@msymt
Last active September 12, 2020 13:50
Show Gist options
  • Save msymt/0b0bba4bf5121d2a1ac7f8d9fe366a37 to your computer and use it in GitHub Desktop.
Save msymt/0b0bba4bf5121d2a1ac7f8d9fe366a37 to your computer and use it in GitHub Desktop.
[Android]Espresso でperform(scrollTo())をしても見つけてくれない場合

起こり得るケース

scrollView内にて、画面外に設置したviewにアクセスする際

対処法

R.id.buttonにアクセスする時を想定する

通常の手法

通常はこのようにscrollTo()でwithIdで指定したviewまでスクロールするはずです。

onView(withId(.id.button)).perform(scrollTo(), click())

上が無理な場合

これならscrollViewの底までscrollするはずです。

onView(withId(R.id.scrollView)).perform(swipeUp())

参考

https://stackoverflow.com/questions/30387255/espresso-how-to-scroll-to-the-bottom-of-scrollview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment