0

I'm running some test automation on a Windows application with Appium and WebDriverIO. I need to scroll in a certain part of my application, but can't figure out how to do it.

I've tried leveraging WebDriverIO's scrollIntoView() method, but I'm getting a Could Not Proxy error (maybe because WinAppDriver doesn't handle this method?)

I've also tried browser.touchScroll(xOffset: int, yOffset: int, string?:ElementID, but I'm confused on the last parameter. In order to interact with UI elements, I've been using the accessibilityID selector method ('~'). But the parameter simply asks for a string, not an Element. I've tried using the ~ and also just putting in the accessibilityID of the element, but it's not finding the element.

Does anyone have an idea that can help me? I'd appreciate it!

lakers5824
  • 345
  • 1
  • 2
  • 10
  • I've also tried `.moveTo()`, but I'm getting the same Error. "Error: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: Request failed with status code 501" – lakers5824 Oct 07 '21 at 20:51

1 Answers1

0

Maybe this method works for your Windows app, this works pretty well for scrolling downwards until the MobileElement becomes visible in the screen for Appium. All you have to do is give your MobileElement in the scrollAndFind(...); and it will magically scroll and find it.

    public static void scrollAndFind(MobileElement element) {
        WebDriverWait wait = new WebDriverWait(driver, 2);

        int startX = (int) ((driver.manage().window().getSize().getWidth()) * 0.50);
        int endX = (int) ((driver.manage().window().getSize().getWidth()) * 0.50);
        int startY = (int) ((driver.manage().window().getSize().getHeight()) * 0.80);
        int endY = (int) ((driver.manage().window().getSize().getHeight()) * 0.20);

        int max = 10;
        boolean found = false;

        while (max > 0 && !found) {

            try {
                wait.until(ExpectedConditions.elementToBeClickable(element));
                found = true;

            } catch (Exception e) {
                new TouchAction<>(driver)
                        .press(PointOption.point(startX, startY))
                        .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))
                        .moveTo(PointOption.point(endX, endY))
                        .release()
                        .perform();
                max--;
            }
        }
    }
kenneth
  • 478
  • 4
  • 11