简体   繁体   English

如何通过 Python 客户端使用 Appium 滚动 Android 应用程序

[英]How to scroll Android app with Appium by Python Client

I'm testing Android application and need to scroll text.我正在测试 Android 应用程序,需要滚动文本。 I have tried everything I found here and on a Internet but nothing is working.我已经尝试了我在这里和互联网上找到的所有东西,但没有任何效果。

Appium v1.4.1 (Server v1.7.2) Python 3.x Using selenium webdriver Appium v​​1.4.1 (Server v1.7.2) Python 3.x 使用 selenium webdriver

I need scroll to the bottom of a page, not to specific element我需要滚动到页面底部,而不是特定元素

The closest is最接近的是

self.driver.execute_script("mobile: scroll", {"direction": "up"}) 

but it is not working .但它不起作用。 Log is: selenium.common.exceptions.WebDriverException: Message: Unknown mobile command "scroll".日志是:selenium.common.exceptions.WebDriverException:消息:未知的移动命令“滚动”。 Only shell commands are supported.仅支持 shell 命令。

Thanks谢谢

For Android there are 2 good options when it takes to scrolling:对于 Android,滚动时有 2 个不错的选择:

actions = TouchActions(driver) el = driver.find_element_by_id(<id of element you press to start swipe>) action.press(el).move_to(x=100, y=-1000).release().perform()

You can also get screen size of the device to scroll more precisely:您还可以获取设备的屏幕尺寸以更精确地滚动:

screen_size = driver.get_window_size()

self.driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().resourceId("<id of scrollable view>")).scrollIntoView(new UiSelector().resourceId("<id of element to scroll to>"))')

You can read more here你可以在这里阅读更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java Appium Client在Android中滚动? - How to scroll in android using java appium client? 如何使用appium在android应用程序中滚动表单 - How to scroll form in android app using appium 无法使用Java客户端使用Appium滚动Android应用程序 - Unable to scroll Android app with Appium using Java Client 如何使用 Appium 和 Python 在 android 应用程序中滚动列表一次 - How to scroll list once in android application using Appium and Python Android本机应用程序:无法滚动包含200个元素的整个列表(Appium Java客户端) - Android native app: cannot scroll through the entire list which has around 200 elements (appium java client) 无法使用python在带有appium的android中滚动 - Unable to scroll in android with appium using python 如何使用appium在android中滚动listview? - how to scroll a listview in android using appium? 使用appium和python的Android应用程序的功能测试 - Functional test of an android app using appium and python 使用 appium-Javascript 滚动浏览 Android 应用程序 - Scroll Through Android app using appium-Javascript Android / Java / Appium - 向下滑动(滚动)不起作用[移动应用] - Android / Java / Appium - Swipe (Scroll) Down does not work [Mobile App]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM