How to scroll Horizontal

I want to scroll Horizontal on element, till element with specific text so I did:

        getDriver().findElement(MobileBy.AndroidUIAutomator(""new UiScrollable(new UiSelector().scrollable(true).instance(0)).setAsHorizontalList().scrollIntoView(new UiSelector().text(\""+textToSearch+"\"))")).click();

and still the element is not founded and not clicked of course…what to do?
thank you

Maybe you trying scroll wrong view…
How many scroll views you have on screen?

One that is Horizontal and other one is vertical

In your code you selecting some first whatever on page. Try add it id to select 100% needed.

where to add it please?

ID of the element itself or the ID of the scrollable element?

if it’s on the scrollable element it didn’t work neither :

        getDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().resourceIdMatches(\"\").scrollable(true)).scrollIntoView(new UiSelector().text(\""+textToSearch+"\"))")).click();

Try add setAsHorizontalList

Found it, the text was not written correct

@Aleksei, is there any way to make the scroll slower? because when I run the code, the scroll is going too fast and it missed the text,
Thank you


NO. This is pure Android command → UiScrollable  |  Android Developers
Appium just sending it.

o! try add setSwipeDeadZonePercentage and reduce with it scroll area

How it suppose to look with that “setSwipeDeadZonePercentage”?

public void scrollToFirstHorizontalScrollableElement(String textToSearch) {
    getDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true)).setAsHorizontalList().scrollIntoView(new UiSelector().text(\""+textToSearch+"\"))")).click();

After .setAsHorizontalList().setSwipeDeadZonePercentage(0.2)

Not sure for 0.2. Try different 0.3, 0.5

I tried 0.3 and didn’t succeed :frowning:

It should scroll less. Try other values. 0.5, 10, 50