scroll_to stops working appium1.4

I am trying to navigate through a set of device folders.
element_click(get_device_folders(‘storage’))
sleep(3)
element_click(get_device_folders(‘emulated’))
element_click(get_device_folders(‘0’))
element_click(get_device_folders(‘My Documents’))
element_click(get_device_folders(‘automation word doc.docx’))

def get_device_folders(folder_name)
scroll_to(folder_name)
end

In the above flow, driver scrolls to find ‘storage’ folder, but stops for emulated, if I manually bring emulated in view, it finds and clicks it. Then continues working for the test of the folders.

Here are the logs:
No element found (Selenium::WebDriver::Error::NoSuchElementError)

Appium logs:
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:"-android uiautomator",“selector”:“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”));”,“context”:"",“multiple”:false}]
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)).scrollIntoView(new UiSelector().textContains(“emulated”));”,“context”:"",“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”)); using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing scrollable: new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”))
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0
info: [debug] [BOOTSTRAP] [debug] UiScrollable invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException args: new UiSelector().textContains(“emulated”),
info: [debug] [BOOTSTRAP] [debug] UiScrollable coerce type: class com.android.uiautomator.core.UiObject arg: new UiSelector().textContains(“emulated”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “emulated”
info: [debug] [BOOTSTRAP] [debug] Method name: scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Setting uiObject for scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException with: com.android.uiautomator.core.UiObject@41f827b8
info: [debug] [BOOTSTRAP] [debug] Ignoring UiObjectNotFoundException when using reflection to invoke method.
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CONTAINS_TEXT=emulated]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”)); using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing scrollable: new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”))
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0
info: [debug] [BOOTSTRAP] [debug] UiScrollable invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException args: new UiSelector().textContains(“emulated”),
info: [debug] [BOOTSTRAP] [debug] UiScrollable coerce type: class com.android.uiautomator.core.UiObject arg: new UiSelector().textContains(“emulated”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “emulated”
info: [debug] [BOOTSTRAP] [debug] Method name: scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Setting uiObject for scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException with: com.android.uiautomator.core.UiObject@41f10808
info: [debug] [BOOTSTRAP] [debug] Ignoring UiObjectNotFoundException when using reflection to invoke method.
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CONTAINS_TEXT=emulated]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“No element found”,“status”:7}
info: [debug] Waited for 23284ms so far
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:"-android uiautomator",“selector”:“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”));”,“context”:"",“multiple”:false}]
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)).scrollIntoView(new UiSelector().textContains(“emulated”));”,“context”:"",“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”)); using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing scrollable: new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”))
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0
info: [debug] [BOOTSTRAP] [debug] UiScrollable invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException args: new UiSelector().textContains(“emulated”),
info: [debug] [BOOTSTRAP] [debug] UiScrollable coerce type: class com.android.uiautomator.core.UiObject arg: new UiSelector().textContains(“emulated”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “emulated”
info: [debug] [BOOTSTRAP] [debug] Method name: scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Setting uiObject for scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException with: com.android.uiautomator.core.UiObject@41ee6ae0
info: [debug] [BOOTSTRAP] [debug] Ignoring UiObjectNotFoundException when using reflection to invoke method.
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CONTAINS_TEXT=emulated]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”)); using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing scrollable: new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“emulated”))
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0
info: [debug] [BOOTSTRAP] [debug] UiScrollable invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException args: new UiSelector().textContains(“emulated”),
info: [debug] [BOOTSTRAP] [debug] UiScrollable coerce type: class com.android.uiautomator.core.UiObject arg: new UiSelector().textContains(“emulated”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “emulated”
info: [debug] [BOOTSTRAP] [debug] Method name: scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Setting uiObject for scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException with: com.android.uiautomator.core.UiObject@41fc74d8
info: [debug] [BOOTSTRAP] [debug] Ignoring UiObjectNotFoundException when using reflection to invoke method.
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CONTAINS_TEXT=emulated]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“No element found”,“status”:7}
info: [debug] Condition unmet after 46647ms. Timing out.
info: [debug] Responding to client with error: {“status”:7,“value”:{“message”:“An element could not be located on the page using the given search parameters.”,“origValue”:“No element found”},“sessionId”:“5dd42de5-7f9d-4ffa-8276-b85f7e1d44d8”}
info: <-- POST /wd/hub/session/5dd42de5-7f9d-4ffa-8276-b85f7e1d44d8/element 500 46650.479

Diana,

What version of Appium were you using previously? scroll_to() wasn’t working in 1.3.3 either, and there’s a ticket opened on github against this. If you were using 1.3.3+ before you upgraded to 1.4, then I can’t explain the problem. Otherwise, I’ve posted a work-around for this problem on this board several times (and can dig it up again if you can’t find it).

@willosser

Thanks for the reply.

To answer you question I first tried it on 1.3.7 and because it did not work I moved to 1.4, some forums mentioned it was working in 1.4.

My case of scroll is working on one scenario but not in the other.

When I am trying to add a file from the device into my app if i use the below folder hierarchy
storage/emulated/0/Legacy/My Documents, the driver does not scroll to find emulated. In the middle of the test if I click emulated the driver would work prefectly for 0/Legacy/My Documents

If I use the other path:
sdcard/My Documents the scroll works fine. I am currently using the later approach.

P.S: I found your posts and replies.

For me, some how scrollToExact worked more consistently that scrollTo…
Try using scrollToExact