如何在 ScrollTo 和 ScrollToExact 被弃用后滚动到

How to ScrollTo after ScrollTo and ScrollToExact were deprecated

我注意到 ScrollTo 已被弃用,但没有找到滚动到页面上任何网络元素的任何好的解决方案。

Question:

谁能帮我弄清楚现在在 C#(Android 设备)中执行此操作的最佳方法是什么?

据我了解,您可以使用的唯一滚动方法是

driver.swipe(int startx, int endx, int starty, int endy, int duration);

您可以使用上述方法和以下方法构建一个 swipeTo 函数:

driver.manage().window.size().getHeight() // and .getWidth()
//Note I am recalling that one from memory as I do not have access to my appium program currently
el.getLocation().getX() //getY()
el.getSize().getWidth() // getHeight()

只需一点数学知识,您就可以将它们变成 swipeTo 方法。

是的,在 ScrollTo 和 ScrollToExact 被弃用后,您的正确 ScrollTo,请在此处找到替代解决方案,

MobileElement radioGroup = (MobileElement) wd
                .findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()"
                        + ".resourceId(\"<your listview or any scrollview id>\")).scrollIntoView("
                        + "new UiSelector().text(\"+<your text>+\"));");
        radioGroup.click();

有关更多信息,请观看此视频: https://www.youtube.com/watch?v=bT3tqaLNn-Y