서론
앞서 간단한 버튼클릭에 대해 설명했는데요. 이번엔 Drag를 하여 ScrollView를 조작하는 방법에 대해 설명하겠습니다.
스크롤뷰 만들기
- 아래와 같이 Hierarchy창에서 Canvas를 우클릭 후 ScrollView를 만들어주세요.

- Scene창에서 ScrollView를 Button아래로 옮기고 사이즈를 아래와 같이 세로를 조금 줄여주세요.

- Hierarchy창에서 ScrollView > Viewport > Content를 클릭하고 Inspector에서 Add Component를 눌러 Vertical Layout Group을 추가해주세요.

- Vertical Layout Group을 아래와 같이 설정해주세요.

- Hierarchy창에서 ScrollView > Viewport > Content를 우클릭하고 버튼을 추가해주세요.

- 아래와 같이 Scrollview안에 Button이 추가되었습니다.

- Hierarchy창에서 추가된 Button 아래 Text를 클릭하고 Inspector에서 Text를 Box1으로 변경해주세요.

- Button을 클릭하고 Ctrl(Cmd) + C를 입력하여 Button을 복사해주세요.

- Ctrl(Cmd) + V를 5번 입력하여 버튼을 5개 추가해주세요.

- 추가된 버튼들 하위 Text를 클릭하고 Box2, Box3, ..., Box6 까지 각자 입력해주세요.

Box6가 나올때까지 스크롤하기 그리고 클릭하기
gamium-testing
하위에test.py
파일을 아래와 같이 수정해줍니다.
from gamium import *
# 드라이버 세션을 시작합니다.
service = TcpGamiumService("127.0.0.1", 50061)
gamium = GamiumClient(service)
# 연결을 시작합니다.
gamium.connect()
# ui를 조작할 수 있는 객체를 가져옵니다.
ui = gamium.ui()
# 버튼을 클릭합니다.
ui.click(By.path("/Canvas[1]/Button[1]"))
# 스크롤바 핸들을 찾습니다.
scrollBar = ui.find(By.path("/Canvas[1]/Scroll View[1]/Scrollbar Vertical[1]/Sliding Area[1]/Handle[1]"))
# box6를 찾습니다.
box6 = ui.find(By.path("/Canvas[1]/Scroll View[1]/Viewport[1]/Content[1]/Button (5)[1]"))
# box6가 보일 때까지 스크롤바를 드래그하는 함수 입니다. 성공시 True를 반환합니다.
def wait_until_box6():
result = gamium.try_wait(Until.element_interactable(box6), WaitOptions(300))
if True == result.success:
result.value.click()
return True
scrollBar.drag(Vector2(scrollBar.info.position.x, scrollBar.info.position.y - 10))
return False
# wait_until_interactable 함수가 True를 지속적으로 함수를 호출합니다.
gamium.wait(wait_until_box6, WaitOptions(timeout_ms=10000))
- Unity Editor창에서 Play버튼을 누릅니다.
- VSCode 터미널에서 아래 명령어를 통해 실행해봅니다.
python3 test.py
이제 버튼이 클릭되어 아래와 같이 Clicked로 메시지가 변경하는것을 확인할 수 있습니다. 👏
0:00
/
📖
Dogu Technologies - Seamless Test Automation Platform
Revolutionize your testing workflow with our game and application test automation platform. Execute automated tests using Dogu and optimize your software quality assurance.
