在appium中滑动或滚动到底部

编程入门 行业动态 更新时间:2024-10-21 14:24:31
本文介绍了在appium中滑动或滚动到底部-android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使用appium在Android应用程序中将滚动条滑动到底部? 我尝试使用

How can I swipe scroll to bottom in an android app using appium? I tried using

driver.swipe(300,800,300,500,2); driver.scrollTo("string")

但是上面没有帮助.谁能建议我一些通用的解决方案?

But above did not helped. Can anyone suggest me some generic solution ?

推荐答案

通用解决方案将使用尺寸进行滚动.使用以下代码

A generic solution will be scrolling using dimensions. use the below code

public void scroll() throws IOException { try { Dimension dimensions = driver.manage().window().getSize(); System.out.println("Size of screen= " +dimensions); int Startpoint = (int) (dimensions.getHeight() * 0.5); System.out.println("Size of scrollStart= " +Startpoint ); int scrollEnd = (int) (dimensions.getHeight() * 0.2); System.out.println("Size of cscrollEnd= " + scrollEnd); driver.swipe(0, Startpoint,0,scrollEnd,1000); } catch (IOException e) { } }

将此添加到我们的代码中,只需使用scroll();即可.在您的测试用例中.修改代码中给出的十进制值以满足您的要求

add this to ur code and simply use scroll(); in ur test case. Modify the decimal values given in the code to nmeet your requirements

更多推荐

在appium中滑动或滚动到底部

本文发布于:2023-11-28 21:00:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:appium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!