How to scroll properly without selecting a text?

I am trying to scroll an Android smartphone with Python. I am using this method:

driver.swipe(start_x, start_y, end_x, end_y, 1000)

But I have a problem: When there is a long text, it is selecting the text for copying-pasting it.
So I search for solution, and I found this one:

https://stackoverflow.com/questions/60976160/scroll-down-method-selects-text-in-appium

It proposes to use “TouchAction” but this is deprecated.

So I search for other methods:

ActionChains(driver).click_and_hold request element to start and element to end the scroll. But I need to scroll from y positions, not elements.

My Pycharm suggest me other methods like:

scroll_by_amount
scroll_from_origin

But I didn’t find any doc about these methods.

Does anyone already face this issue? Any solution for this kind of problem?

You are talking about this:

According to that issue, TouchAction is replaced by MobileGesture:

Python Scroll example at the bottom of this page:

https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-mobile-gestures.md

Hello, I have been facing the same issue. After plenty of try error, I end up with this and it works fine.

 Dimension phoneSize = appiumDriver.manage().window().getSize();

        int height = phoneSize.getHeight() * 6 / 10;
        int width = phoneSize.getWidth();
        int left = appiumDriver.manage().window().getPosition().getX();
        int top = appiumDriver.manage().window().getPosition().getY() / 10;

        appiumDriver.executeScript("mobile: scrollGesture",
                ImmutableMap.of(
                        "left", left,
                        "top", top,
                        "width", width,
                        "height", height,
                        "direction", "down",
                        "percent", 1.0,
                        "speed", 100));
    }
}
1 Like

Thanks, @Lokman_Gunay. I can see one of the links I posted is no longer valid. Here is where it’s moved to, Python example at the bottom: