question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android UiScrollable - unable to use methods that do not result in a UiObject/UiSelector

See original GitHub issue

I’m trying to implement my own version of scrollTo, and to do that on Android, I decided to use UiAutomator api methods.

Seeing how Appium supports both UiSelectors and UiScrollable, I figured the following would work to scroll to the top of the scrollable element: driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollToBeginning(10);"));

It does not work, as I get the following:

2015-03-18 11:15:59:863 - info: [debug] Pushing command to appium work queue: ["find",{"strategy":"-android uiautomator","selector":"new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollToBeginning(10);","context":"","multiple":false}]

2015-03-18 11:15:59:866 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollToBeginning(10);","context":"","multiple":false}}

2015-03-18 11:15:59:867 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION

2015-03-18 11:15:59:867 - info: [debug] [BOOTSTRAP] [debug] Got command action: find

2015-03-18 11:15:59:867 - info: [debug] [BOOTSTRAP] [debug] Finding new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollToBeginning(10); using ANDROID_UIAUTOMATOR with the contextId:  multiple: false

2015-03-18 11:15:59:867 - info: [debug] [BOOTSTRAP] [debug] Parsing scrollable: new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollToBeginning(10)

2015-03-18 11:15:59:867 - info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true

2015-03-18 11:15:59:867 - info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0

2015-03-18 11:15:59:868 - info: [debug] [BOOTSTRAP] [debug] UiScrollable invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollToBeginning(int) throws com.android.uiautomator.core.UiObjectNotFoundException args: 10, 

2015-03-18 11:15:59:868 - info: [debug] [BOOTSTRAP] [debug] UiScrollable coerce type: int arg: 10

2015-03-18 11:15:59:868 - info: [debug] [BOOTSTRAP] [debug] Method name: scrollToBeginning

2015-03-18 11:15:59:868 - info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Could not parse UiSelector argument: Must only call the 'scrollIntoView' method OR methods on UiScrollable which return UiScrollable or UiObject objects","status":9}

2015-03-18 11:15:59:868 - info: [debug] Condition unmet after 5136ms. Timing out.

2015-03-18 11:15:59:869 - info: [debug] Responding to client with error: {"status":9,"value":{"message":"The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.","origValue":"Could not parse UiSelector argument: Must only call the 'scrollIntoView' method OR methods on UiScrollable which return UiScrollable or UiObject objects"},"sessionId":"851c3676-5f27-403e-b33d-67c093b6b2f4"}

I’m guessing that the log of interest is the following:

    {"value":"Could not parse UiSelector argument: Must only call the 'scrollIntoView' method OR methods on UiScrollable which return UiScrollable or UiObject objects","status":9}

My method doesn’t return a UiScrollable or UiObject object. It simply scrolls to the top of the screen using the scrollable element, and I confirmed that the scrollable UiSelector is correct.

I tried ScrollToBeginning, flingToBeginning, flingToEnd and all related methods that scroll based on steps.

Am I doing something wrong or are the scrolling methods (other than scrollIntoView) not supported in Appium?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:2
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
SrinivasanTargetcommented, May 23, 2016

ScrollTo is deprecated in java-client.please look into this for better approach https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/ios/IOSScrollingSearchingTest.java

Closing this.

3reactions
SrinivasanTargetcommented, May 23, 2016

@triager please close

Read more comments on GitHub >

github_iconTop Results From Across the Web

UiScrollable not work in Android uiautomator - Stack Overflow
When I use the class UiScrollabl " to find some objects in a scrollable object, it can't find the object if the the...
Read more >
UiScrollable - Android Developers
Searches for a child element in the present scrollable container that matches the selector you provided. The search is performed without scrolling and...
Read more >
Scrolling using UiScrollable stops in the middle of the screen
I am trying to scroll down to the bottom of the screen to a UI block using UiSelector class but it's not working...
Read more >
Custom utility methods to scroll using appium [Android & iOS]
This video will explain how to scroll -- till an element found -- till a text found from list of items Create utility...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found