如何在Appium-Android中向上/向下滚动 [英] How to scroll up/down in appium-android

查看:75
本文介绍了如何在Appium-Android中向上/向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序页面,我需要在其中垂直滚动才能到达该应用程序的某个元素.

I have an app page where I need to scroll vertically to reach an element of the app.

我已经在Google上搜索并尝试了许多解决方案.许多命令已被弃用,并且在appium中不再支持.另外,Stack中的先前问题/答案也无济于事. 我正在使用appium v​​1.13.0 + Java(IntelliJ).

I've googled and tried many solutions. Many commands are deprecated and don't support anymore in appium. Also, previous questions/answers in Stack didn't help me. I'm using appium v1.13.0 + Java (IntelliJ).

有时我会看到此错误:

java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen

无论如何,我的问题不只是解决提到的错误.我正在寻找可行且正确的命令来使appium进行滚动操作. 请带给我完整的示例项目,因为我是大三. 谢谢

Anyway, my problem isn't just to solve the mentioned error. I'm looking for workable and correct commands to make a scroll action with appium. Please bring me the complete sample project cause I'm junior. Thanks

推荐答案

尝试一下

String scrollViewContainer_finder = "new UiSelector().resourceIdMatches(\".*id/your_scroll_view_id\")";
String neededElement_finder = "new UiSelector().resourceIdMatches(\".*id/elemnt1\")";

WebElement abc = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(" + scrollViewContainer_finder + ")" +
                ".scrollIntoView(" + neededElement_finder + ")"));

这篇关于如何在Appium-Android中向上/向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆