0

Test has a dropdown list in it. The recorder caught the click to open the dropdown of choices. But then the click to select one is failing with the following error:

Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
at least 90 percent of the view's area is displayed to the user.

This question Android Espresso error on button click deals with the constraint, but its suggestion to simply use isCompletelyDisplayed() does not work.

Community
  • 1
  • 1
Rob
  • 11,446
  • 7
  • 39
  • 57
  • to clarify: with "picker" or "dropdown" you mean a spinner? how do you spinner elements look like and how many are there to choose from? – stamanuel Mar 12 '17 at 19:01
  • This is a simple dropdown menu, not a picker. Yes just a spinner. – Rob Mar 12 '17 at 20:52

1 Answers1

1

Yep, that happens when the view that you are clicking is at a scroll position that makes it invisible to the user.

Just use:

onView(withId(whatever)).perform(scrollTo(), click())

I am assuming that your view can be targeted with an onview selector.

  • Thinking the recorder was a way to see how Espresso does stuff was my first mistake. Making some progress with it now. Your answer does not address with what this question was about, because this spinner all the choices are displayed on click, but I was wondering how to do this exact thing too so +1. Thanks. – Rob Mar 13 '17 at 05:35
  • but i mean, click on the button that opens the spinner, then target the view on the spinner and perform scroll and click on it – Javier Ventajas Hernández Mar 13 '17 at 07:51
  • I know what you mean. What I am saying is when the click registers, the values appear and no scrolling is necessary. The 90% thing was coming up on the click of the spinner itself. – Rob Mar 13 '17 at 13:21
  • If the spinner click triggers the 90% error, then use scrollTo action on that click as well – Javier Ventajas Hernández Mar 13 '17 at 14:35
  • I will revisit that. I finally did get a relatively clean test working which is nice. Of course, by abandoning all hope of the recorder getting me there. For now, I simply defining an inline ViewAction. – Rob Mar 13 '17 at 15:14
  • I'm glad you figured it out. :) – Javier Ventajas Hernández Mar 13 '17 at 15:23