Smo*_*ogy 7 javascript appium webdriver-io android-uiautomator react-native
无论我如何尝试,我都无法让我的 React Native (Android) 应用程序使用 Appium 向下滚动。
我正在使用 UiAutomator2 和 WebdriverIO。
我的代码如下所示:
scrollUntilDisplayed(element: WebdriverIO.Element) {
const dimensions = driver.getWindowSize();
touchScroll(10, 100);
}
Run Code Online (Sandbox Code Playgroud)
touchScroll我尝试了以下调用来代替:
driver.touchScroll(offsetX, offsetY)- 抛出错误 ( invalid argument: java.lang.IllegalArgumentException: ScrollToModel: The mandatory field 'params' is not present in JSON)driver.touchScroll(offsetX, offsetY, element)- 抛出错误 ( invalid argument: java.lang.IllegalArgumentException: ScrollToModel: The mandatory field 'params' is not present in JSON)browser.execute("mobile: scroll", {direction: 'down'});- 抛出错误 ( 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);- 什么也没做; 一直坐到 Appium 超时element.scrollIntoView();- 什么也没做小智 9
由于 ReactNative 有 NATIVE_APP 上下文(作为常规 Android 应用程序),您可以使用uiautomator 选择器:
const bottomElementSelector = `new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().text("Element label text"))`
const bottomEl = $(`android=${bottomElementSelector}`)
Run Code Online (Sandbox Code Playgroud)
搜索具有可滚动选择器的元素应将焦点向下移动到该元素
注意:确保您在 Appium 功能中使用 UiAutomator2
| 归档时间: |
|
| 查看次数: |
11074 次 |
| 最近记录: |