简体   繁体   English

混合应用程序:无法使用C#和Appium向下滚动?

[英]Hybrid App: Unable to scroll down using C# and Appium?

I have been trying to scroll down the page in my hybrid mobile application in order to perform action(s) on the elements which are not in focus. 我一直试图在混合移动应用程序中向下滚动页面,以便对未重点关注的元素执行操作。 Off focus, mobile driver is able to find locators but unable to perform action(s).I tried various solutions across, but it seems to work with android native apps but not in hybrid apps. 偏离焦点时,移动驱动程序能够找到定位器,但无法执行操作。我尝试了各种解决方案,但它似乎适用于Android本机应用程序,但不适用于混合应用程序。

            var loc = FindElement(locator).Location;
            if ((IsDisplayed(locator)))
            {
                GetActionsObj().MoveTo(loc.X, loc.Y).Wait(10000).Perform();
            }

We are getting the exception as "Failed to execute touch event".. We have also tried using 我们收到异常消息“无法执行触摸事件”。我们也尝试使用

AndroidDriver.Swipe(),Tap()... Nothing worked.

Please help. 请帮忙。

In java, i use to swipe like following. 在Java中,我经常像下面这样滑动。

I am not sure if this works on c#. 我不确定这是否适用于C#。

Just give it a try. 试一试。

 public void swipe(int startX, int endX, int startY, int endY){
        try {
            new TouchAction(driver).press(PointOption.point(startX, startY)).waitAction(WaitOptions.waitOptions(ofSeconds(1)))
                    .moveTo(PointOption.point(endX, endY)).release().perform();
        } catch (Exception e) {
            System.out.println("unable to swipe");
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM