Automation/Appium

Scroll

c29130811 2023. 7. 15. 23:14

Appium에서 스크롤 액션을 하는 경우 Swipe를 쓰는 경우와, TouchAction 을 가져다 쓰는 방법 두가지가 있다. 

 

1. TouchAction에서 Long_press 로 move_to를 이어서 사용하는 방법

from appium.webdriver.common.touch_action import TouchAction

actions = TouchAction(self.driver)
actions.long_press(None,screenWidth/2,screenHeight*0.8).move_to(None,screenWidth/2,screenHeight*0.1).release().perform()

 

2. 간단하게 Swipe를 통해, 시작부터 끝의 좌표를 사용하여 Scroll하는 방법

self.driver.swipe(start_x=0, start_y=screenHeight*0.7, end_x=0, end_y=screenHeight*0.2, duration=100)

drive에서 swipe를 사용하는 방법으로, 시작하는 x, y 좌표부터 종료하는 x, y 좌표를 파라미터와 속도까지 duration을 입력하여 사용 할 수 있다. 이때 디바이스의 해상도는 

deviceSize = self.driver.get_window_size()
screenWidth = deviceSize['width']
screenHeight = deviceSize['height']

get_window_size를 통해 가져올 수 있으며, width에 0.7 즉 70% 해당하는 위치를 계산하여 스크롤 하는 경우가 있다. 

화면 좌표는 Android 에서 https://developer.android.com/studio/debug/dev-options?hl=ko를 통해 가져올 수 있다. 

 

온디바이스 개발자 옵션 구성  |  Android 스튜디오  |  Android Developers

앱 성능을 프로파일링하고 디버그하는 데 도움을 주는 시스템 동작을 구성하는 방법을 자세히 알아보세요.

developer.android.com

자세한건 browserstack에 정리 된 글이 있으니, 참고해봐도 좋을 듯

https://www.browserstack.com/guide/touch-actions-in-appium

 

How to use touch actions in Appium? | BrowserStack

Learn what are different touch actions in Appium like Tap, Swipe, Long Press, Swipe with Touch Actions, multiple touch actions, along with best practices

browserstack.wpengine.com

오늘도 Appium 공부 하하하하.

728x90

'Automation > Appium' 카테고리의 다른 글

Appium, WebdriverIO  (0) 2024.09.20
click, send_keys  (0) 2023.06.26
Appium - Browserstack  (0) 2023.06.03
Appium 2.0 시작 및 준비물  (0) 2023.05.07