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:
driver.touchScroll(offsetX, offsetY)
- throws an error (invalid argument: java.lang.IllegalArgumentException: ScrollToModel: The mandatory field 'params' is not present in JSON
)driver.touchScroll(offsetX, offsetY, element)
- throws an error (invalid argument: java.lang.IllegalArgumentException: ScrollToModel: The mandatory field 'params' is not present in JSON
)browser.execute("mobile: scroll", {direction: 'down'});
- throws an error (unknown error: An unknown server-side error occurred while processing the command. Original error: Both strategy and selector arguments must be provided
)driver.touchFlick(0, dimensions.height, undefined, 10000, 10000, 10000);
- does nothing; sits until Appium times outelement.scrollIntoView();
- does nothingSince 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