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

如何到达appium滚动条的末端?

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

如何到达appium滚动条的末端?

如果页面底部有任何元素或文本,则可以使用UiAutomator2。

如果您使用的是appium,请添加所需的功能’UiAutomator2’。

capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");

现在,如果您有元素的ID,请使用以下函数

 public void scrollByID(String Id, int index) {        try {  driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(""+Id+"").instance("+index+"));"));        } catch (Exception e) {e.printStackTrace();        }    }

如果您有元素的文本,请使用它。

public void scrollByText(String menuText) {        try {  driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches("" + menuText + "").instance(0));"));         } catch (Exception e) {e.printStackTrace();        }    }

如果您不知道botton中的任何元素,则必须使用屏幕尺寸

public void scrollToBottom() {      int  x = driver.manage().window().getSize().width / 2;      int start_y = (int) (driver.manage().window().getSize().height * 0.2);      int end_y = (int) (driver.manage().window().getSize().height * 0.8);        TouchAction dragNDrop = new TouchAction(driver)  .press(PointOption.point(x,start_y)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(500)))  .moveTo(PointOption.point(x, end_y))  .release();        dragNDrop.perform();    }


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

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

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