appium: Android UiScrollable - unable to use methods that do not result in a UiObject/UiSelector
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?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 26 (10 by maintainers)
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.
@triager please close
@smaspe Looks interesting.Will look into this.
Is there any update on this?? Getting the same issue: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Method name: scrollToEnd [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:9,“value”:“Could not parse UiSelector argument: Must only call the ‘scrollIntoView’ method OR methods on UiScrollable which return UiScrollable or UiObject objects”}
driver.findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollToBeginning(10);”) Try using this might help as i am using driver.findElementByAndroidUIAutomator method to scroll
Hey @smaspe Thanks for pointing this. Would be good if you could paste the latest gist here inform of gist.