簡體   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