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

fix scroll #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

fix scroll #42

wants to merge 2 commits into from

Conversation

paweltomaszewskisaucelabs
Copy link

@paweltomaszewskisaucelabs paweltomaszewskisaucelabs commented Sep 27, 2024

Because of nested scrollable element time to time scroll down (swipe up) will end up with going into wrong direction. I did a fix to make scroll works for native full page screenshot test in visual e2e repo.

@diegoperini
Copy link
Contributor

diegoperini commented Oct 8, 2024

We can merge this if this is urgent but I'd rather not rely upon presence of espresso classes as a way to enable a feature or not. Mocks of those classes can go into an app even outside of a testing context.

An alternative approach is we can define a property to enable/disable this explicitly. The property can be false by default and test code can have access to the Activity reference and call the setter to set it to true.

@@ -35,6 +35,15 @@ public class ProductCatalogFragment extends BaseFragment implements View.OnClick
ProductsAdapter adapter;
ProductCatalogViewModel viewModel;

public static boolean isRunningEspressoTest() {
Copy link

@shahrukhamd shahrukhamd Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to understand if this check is actually needed. I mean, why can't we just enable nested scrolling android:nestedScrollingEnabled="true"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a better approach indeed. If it works, please ignore my alternative solution (accessing activity reference in test code) above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to understand if this check is actually needed. I mean, why can't we just enable nested scrolling android:nestedScrollingEnabled="true"

As I mentioned in description, scrolling down time to time ends up with scrolling up which breaks taking full page screenshot in our tests. The issue is fixed after turning off nestedScrollingEnabled

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then please create a function in the fragment that does this:

binding.productRV.setNestedScrollingEnabled(true);

and call that function explicitly in the test class so that you can safely remove isRunningEspressoTest() from the fragment entirely.

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

Successfully merging this pull request may close these issues.

3 participants