Appium cannot scroll when there is a tab with 'selected' attribute 'true'


Hello guys,
My issue is that when there is a tab or a navigation bar with the ‘selected’ attribute set to ‘true’, I cannot perform the vertical scroll. It always seem to be stuck at that tab label as shown in the picture. Any other screen without this kind of tab bar, I can perform the vertical scrolling. How can I resolve this?

  1. show App Source a bit below
  2. add code how you tried

await $(‘android=new UiScrollable(new UiSelector().scrollable(true)).scrollToEnd(1,5)’)

I am testing this piece of code.


Works on this kind of screen.


But does not work for this kind of screen. By this kind, I mean by the way there is a navigation tab in this screen.

My current solution is this:

async function scroll(startXRatio, startYRatio, endXRatio, endYRatio, durationMiliSec) {

const d = await driver.getWindowRect();

const height = d.height;

const width = d.width;

const swipeStartWidth = (width * startXRatio) / 100;

const swipeStartHeight = (height * startYRatio) / 100;

const swipeEndWidth = (width * endXRatio) / 100;

const swipeEndHeight = (height * endYRatio) / 100;

await driver.touchPerform([

    { action: 'press', options: { x: swipeStartWidth, y: swipeStartHeight } },

    { action: 'wait', options: { ms: durationMiliSec } },

    { action: 'moveTo', options: { x: swipeEndWidth, y: swipeEndHeight } },

    { action: 'release' }

]);

}

Means take FIRST scrollable view. In your problematic screen first is HorizontalScrollView with tabs.

You need add id of needed view to scroll. On your screenshot it should be below.

example:

new UiScrollable(new UiSelector().resourceIdMatches(\".*part_id.*\").scrollable(true)).scrollToEnd(1,5)
// where `part_id` is `tabLayout....` BUT from scrollView below

image

Thank you sir. It worked. But since I could not find the resource-id in the vertical scrollview, I had to use class name instead
new UiScrollable(new UiSelector().classNameMatches(".android.widget.ScrollView.").scrollable(true)).scrollToEnd(1,5)