栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何使用TouchAction使用Appium 1.7.1滚动

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何使用TouchAction使用Appium 1.7.1滚动

我需要滚动查找屏幕外的元素。我想出的是:

  1. 在当前/可见屏幕上搜索所需的元素。
  2. 如果找不到该元素(即不在屏幕上)-
    scrollDown
    (在我的情况下,只需要向下滚动)并再次转到步骤1。我已经将测试限制为4次迭代,因为就我而言,这已经足够了,因此请在此处使用您自己的条件。
    private void scrollDown() {        //if pressX was zero it didn't work for me        int pressX = driver.manage().window().getSize().width / 2;        // 4/5 of the screen as the bottom finger-press point        int bottomY = driver.manage().window().getSize().height * 4/5;        // just non zero point, as it didn't scroll to zero normally        int topY = driver.manage().window().getSize().height / 8;        //scroll with TouchAction by itself        scroll(pressX, bottomY, pressX, topY);    }        private void scroll(int fromX, int fromY, int toX, int toY) {        TouchAction touchAction = new TouchAction(driver);        touchAction.longPress(fromX, fromY).moveTo(toX, toY).release().perform();    }

PS您可以从元素获取坐标并在中使用它

scroll

PSS我用过鸦片1.6.5



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/498267.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号