【问题标题】:How to scroll Android app with Appium by Python Client如何通过 Python Client 使用 Appium 滚动 Android 应用程序
【发布时间】:2018-09-04 06:59:09
【问题描述】:

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

Appium v​​1.4.1(服务器 v1.7.2) Python 3.x 使用 selenium 网络驱动程序

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

最接近的是

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

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

谢谢

【问题讨论】:

  • self.driver.execute_script("mobile: scroll", {"direction": "up"}) 这似乎是我最需要的

标签: android python-3.x selenium-webdriver appium appium-android


【解决方案1】:

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

您可以阅读更多here

【讨论】:

    猜你喜欢
    • 2019-01-03
    • 2015-11-17
    • 2016-08-28
    • 2015-11-12
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 1970-01-01
    相关资源
    最近更新 更多