javascriptreact-nativeappiumwebdriver-ioandroid-uiautomator

Appium - How to scroll down using UiAutomator2 and WebdriverIO with React Native (Android) and JavaScript


No matter what I try, I am unable to get my React Native (Android) app to scroll down using Appium.

I am using UiAutomator2 and WebdriverIO.

My code looks like this:

scrollUntilDisplayed(element: WebdriverIO.Element) {
    const dimensions = driver.getWindowSize();
    touchScroll(10, 100);
}

In place of touchScroll, I have tried the following calls:


Solution

  • Since ReactNative has a NATIVE_APP context (as a regular Android app) you can use uiautomator selector:

    const bottomElementSelector = `new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().text("Element label text"))`
    const bottomEl = $(`android=${bottomElementSelector}`)
    

    Search for an element with srollable selector should move focus down to that element

    Note: Make sure you are using UiAutomator2 in Appium capabilities