Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the ViewPager methods to apply only on displayed widgets #17

Closed
rocboronat opened this issue Feb 16, 2017 · 7 comments
Closed

Change the ViewPager methods to apply only on displayed widgets #17

rocboronat opened this issue Feb 16, 2017 · 7 comments

Comments

@rocboronat
Copy link
Member

In one case, we have a ViewPager inside a ViewPager. Then, the ViewPager that we want to move is repeated over lots of times inside another ViewPager. That makes Espresso to launch a "multiple ViewPagers match that ID". But well, obviously, we want to interact with the ViewPager that is visible.

So:

onView(allOf(ViewMatchers.withId(R.id.the_id), ViewMatchers.isDisplayed())).perform( new ViewAction[] { ViewActions.swipeLeft() });

@rocboronat rocboronat changed the title Add a method to swipe forward the visible ViewPager Change the ViewPager methods to apply only on displayed widgets Feb 16, 2017
@rocboronat
Copy link
Member Author

@Sloy I'll love to have feedback on this idea :·D

@Sloy
Copy link
Member

Sloy commented Feb 16, 2017

Wut? A ViewPager inside a ViewPager both with the same id? That sounds wrong :/

@rocboronat
Copy link
Member Author

Nope, a ViewPager that contains a page that has a ViewPager. So, the ID of the second ViewPager will appear in every page of the first ViewPager, so it will be repeated in the hierarchy tree.

@rocboronat
Copy link
Member Author

Something like this, where the car image is inside a small ViewPager that show lots of pictures of that car, while you can also change the page to take a look to another car:

2017-02-16 17 13 34

If you want to swipe the images' ViewPager, you has match by ID and also look only for displayed ViewPagers.

@Sloy
Copy link
Member

Sloy commented Feb 16, 2017

Now I get it.
I don't have a strong opinion about this...
Seems like adding the isDisplayed is a hack for a specific case. And not only for the ViewPager methods. What about the buttons? Or any other view in that page?

@rocboronat
Copy link
Member Author

Yes, totally. It could apply to lots of things. But, excepting in the Buttons where we do the magic of scrolling until needed, when are you interested in tapping a button that is not visible?

Something to thing about it. No hurries, by the way.

@rocboronat
Copy link
Member Author

Done at #51 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants