繁体   English   中英

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

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

我正在测试 Android 应用程序,需要滚动文本。 我已经尝试了我在这里和互联网上找到的所有东西,但没有任何效果。

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

我需要滚动到页面底部,而不是特定元素

最接近的是

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

但它不起作用。 日志是:selenium.common.exceptions.WebDriverException:消息:未知的移动命令“滚动”。 仅支持 shell 命令。

谢谢

对于 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()

您还可以获取设备的屏幕尺寸以更精确地滚动:

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>"))')

你可以在这里阅读更多

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM