首页 > 解决方案 > 如何在移动应用程序上使用 appium 自动化反应原生轮播?

问题描述

我的移动应用程序引入了需要自动化的轮播。这可以使用 TouchActions 自动化吗?有没有人尝试过?

需要在 Android 和 iOS 上都这样做。

轮播 - https://github.com/meliorence/react-native-snap-carousel

标签: react-nativeautomationappiumios-ui-automation

解决方案


我使用以下内容来处理相同的问题:

public static void pickerWheelByCount(By by, int count, String direction) {
        try {
        AppiumDriver<MobileElement> driver = DriverManager.getDriver();
        HashMap<String, Object> params = new HashMap<>();
        params.put("order", direction);
        params.put("offset", 0.15);
        params.put("element", driver.findElement(by));
        int i = 1;

        while (i <= count) {
            i++;
            driver.executeScript("mobile: selectPickerWheelValue", params);
        } } catch(Exception e) {
            
        }
    }

推荐阅读