获取 WebDriverException:消息:在 iOS 真实设备上使用滚动或滑动关键字(Appium 库)执行脚本时出现未处理的端点

发布于 2025-01-12 11:52:31 字数 525 浏览 1 评论 0原文

我使用 Robot Framework 和 Appium Library 来测试真实设备上本机 iOS 应用程序的脚本。

我需要向下(或向上)滚动到屏幕上某些在视图中不可见的元素,但是当我使用关键字滚动、向下滚动、向上滚动以及适当的元素定位器时,或滑动按百分比滑动,执行脚本时出现相同的错误:

WebDriverException:消息:未处理的端点:/session/[SESSION ID]/execute -- http://[IP]:8100/ 带参数 { 通配符 = ( “会话/[会话 ID]/执行” ); }

我尝试使用 javascript,但没有成功,即出现相同的错误:

Execute Script  driver.execute('mobile: scroll', {direction: 'down'});

有谁知道导致此问题的原因以及如何解决它?

I'm using Robot Framework with Appium Library for test scripts for native iOS application on Real Device.

I need to scroll down (or up) to certain elements on the screen that aren't visible into view, but when I'm using the keywords scroll, scroll down, scroll up with appropriate element locators, or swipe and swipe by percent, I'm getting the same error when executing the script:

WebDriverException: Message: Unhandled endpoint: /session/[SESSION
ID]/execute -- http://[IP]:8100/ with parameters {
wildcards = (
"session/[SESSION ID]/execute"
); }

Additionally I tried by using javascript, but without success i.e. the same error appears:

Execute Script  driver.execute('mobile: scroll', {direction: 'down'});

Does anyone have an idea what causes this problem and how to solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独孤求败 2025-01-19 11:52:31

你可以尝试这个功能:

这对我来说可以处理iOS应用程序的滑动:
我使用的是appium 1.21.0

public void swipeScreen(String direction) {
        int deviceWidth = getDriver().manage().window().getSize().getWidth();
        int deviceHeight = getDriver().manage().window().getSize().getHeight();
        int midX = (deviceWidth / 2);
        int midY = (deviceHeight / 2);
        int bottomEdge = (int) (deviceHeight * 0.85f);

        Dimension size = getDriver().manage().window().getSize();
        int y0 = (int)((double)size.height * 0.7D);
        int y1 = (int)((double)size.height * 0.3D);

        switch (direction.toUpperCase()) {
            case "DOWN":
                new TouchAction(getDriver())
                        .press(PointOption.point(midX, midY))
                        .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
                        .moveTo(PointOption.point(midX, bottomEdge))
                        .release()
                        .perform();
                waitABit(2);
                break;
            case "UP":
                new TouchAction(getDriver())
                        .press((new PointOption()).withCoordinates(midX, y0))
                        .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
                        .moveTo((new PointOption()).withCoordinates(midX, y1))
                        .release()
                        .perform();
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + direction.toUpperCase());
        }
    }

    public void swipeUpScreenToElement(By element) {
        for(int i = 0; i < getExplicitTimeout(); ++i) {
            if (!isPresent(element)) {
                swipeScreen("UP");
            }
        }
    }

    public void swipeDownScreenToElement(By element, int swipeCount) {
        for(int i = 0; i < getExplicitTimeout(); ++i) {
            if (!isPresent(element)) {
                swipeScreen("DOWN");
            }
        }
    }

You can try this function:

This work for me handle swipe for iOS application:
I'm using appium 1.21.0

public void swipeScreen(String direction) {
        int deviceWidth = getDriver().manage().window().getSize().getWidth();
        int deviceHeight = getDriver().manage().window().getSize().getHeight();
        int midX = (deviceWidth / 2);
        int midY = (deviceHeight / 2);
        int bottomEdge = (int) (deviceHeight * 0.85f);

        Dimension size = getDriver().manage().window().getSize();
        int y0 = (int)((double)size.height * 0.7D);
        int y1 = (int)((double)size.height * 0.3D);

        switch (direction.toUpperCase()) {
            case "DOWN":
                new TouchAction(getDriver())
                        .press(PointOption.point(midX, midY))
                        .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
                        .moveTo(PointOption.point(midX, bottomEdge))
                        .release()
                        .perform();
                waitABit(2);
                break;
            case "UP":
                new TouchAction(getDriver())
                        .press((new PointOption()).withCoordinates(midX, y0))
                        .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
                        .moveTo((new PointOption()).withCoordinates(midX, y1))
                        .release()
                        .perform();
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + direction.toUpperCase());
        }
    }

    public void swipeUpScreenToElement(By element) {
        for(int i = 0; i < getExplicitTimeout(); ++i) {
            if (!isPresent(element)) {
                swipeScreen("UP");
            }
        }
    }

    public void swipeDownScreenToElement(By element, int swipeCount) {
        for(int i = 0; i < getExplicitTimeout(); ++i) {
            if (!isPresent(element)) {
                swipeScreen("DOWN");
            }
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文