Rahul sah
Rahul sah

Reputation: 3

Unable to scroll when there are multiple vertical scrolls available in app

Th screen of my app contains two scrollable elements. I am not able to select which particular page to scroll to.

I have tried this:

Logic 1:

MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().resourceId(“com.marrow:id/tvIndexTitle”)).getChildByText(”+ “new UiSelector().className(“android.widget.TextView”), “ADVANCED ORTHOPAEDICS & MANAGEMENT”)”));

Logic 2:

MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().resourceId(“com.marrow:id/tvIndexTitle”)).scrollIntoView(” + “new UiSelector().text(“ADVANCED ORTHOPAEDICS & MANAGEMENT”))”));

I am not able to perform any scroll operation. Please help me regarding this.

Upvotes: 0

Views: 403

Answers (1)

dmle
dmle

Reputation: 3658

In both cases you specified the same id of scrollable view:

new UiSelector().resourceId(“com.marrow:id/tvIndexTitle”)

It explains why you are scrolling within the same boundaries

Suggestions:

  • Find the id of your 2nd scrollable view and replace tvIndexTitle or try with index: new UiSelector().scrollable(true).instance(1)
  • Don't search for exact text: new UiSelector().text(...), use textContains or textStartsWith

Example:

        MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(UiSelector().scrollable(true).instance(1)).scrollIntoView(new UiSelector().textContains(\"ADVANCED ORTHOPAEDICS\"))";

Upvotes: 1

Related Questions