본문 바로가기
🎪 놀고있네/Katalon

[Katalon] Mobile Testing - Scroll to Text

by 냥장판 2021. 2. 6.

 

 

안녕하세요 냥장판 입니다 

모바일에서 element가 있다면 그 element의 text를 찾을 때 까지 스크롤을 다운하고, 해당 text에 도달하면 Tap하는 스크립트를 작성해보겠습니다.

이게 scroll to text 키워드입니다.

 

 

Android apk 파일은 Katalon에서 제공하니 다운로드 하시면 됩니다.

docs.katalon.com/katalon-studio/docs/scroll_element_mobile_automation.html#scroll-to-text

 

Handling Scroll to Element in Mobile Automation

This tutorial illustrates the Scroll Element which contains the given text in the mobile automation via a sample project in Katalon Studio.

docs.katalon.com

 

 

 

1. Test app 파일 위치 확인

.apk 파일 위치는 워크스페이스 > Androidapp 이라는 폴더를 만들고, 그 안에 저장해두었습니다.

 

파일위치는 워크스페이스 > Androidapp > APIDemos.apk 가 되겠죠

2. Test Case 생성

 

Mobile app의 spy 기능을 사용한다면, 미리 TC를 생성하지 않아도 되지만,

TC를 생성하고 script mode로 스크립트를 작성해보도록 할게요.

폴더 > 우클릭 > New > Test Case

 

script mode에 들어가서 아래 코드를 추가합니다.

위에 확인했던 파일위치와 파일명을 확인하여 넣어주시면됩니다.

1
2
3
4
5
6
7
8
// configuration
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
 
'Path of the Apk File Store in path variable'
def path = RunConfiguration.getProjectDir() + '/Androidapp/APIDemos.apk'
 
'Start the application'
Mobile.startApplication(path, false)
cs

 

3. Object 캡쳐하기(Spy Mobile)

액션을 사용할 object를 캡쳐해야합니다.

Spy Mobile > Android Devices 를 클릭합니다.

.apk 파일을 열고 Start 버튼을 클릭합니다.

저는 Graphics 을 찾을거에요. 이 object를 체크하면 captured object에 상세 정보가 로딩됩니다.

 

 

그리고, 모바일에서 graphics 으로 들어간 후, Capture Object를 누르면 화면이 동기화가 되고,

object 목록이 갱신됩니다.

여기서도 똑같이 찾고자 하는 obejct를 캡쳐합니다.

 

캡쳐한 오브젝트들을 저장합니다.

 

 

4. Scroll to Text 사용하기

 

메뉴얼 모드로들어가서 mobile keyword 를 추가합니다.

 

scroll to text 를 클릭합니다.

저는 Graphics 라는 text를 찾을 거에요.

똑같이 UnicodeChart 라는 text를 찾을 거라 같은 키워드를 추가합니다.

 

5. Tap 사용하기

Text까지 스크롤하는 키워드를 사용했으면, Tap을 해야죠

아까 캡쳐해둔 오브젝트를 여기에 사용합니다.

 

실행화면 이에요.

 

 

 

아래 코드 참고하시면 됩니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// configuration
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
 
'Path of the Apk File Store in path variable'
def path = RunConfiguration.getProjectDir() + '/Androidapp/APIDemos.apk'
 
'Start the application'
Mobile.startApplication(path, false)
 
'find Graphics'
Mobile.scrollToText('Graphics', FailureHandling.STOP_ON_FAILURE)
 
'Tap this Graphics'
Mobile.tap(findTestObject('TestMobile_Scrollto/android.widget.TextView - Graphics'), 20)
 
Mobile.scrollToText('UnicodeChart', FailureHandling.STOP_ON_FAILURE)
 
Mobile.tap(findTestObject('TestMobile_Scrollto/android.widget.TextView - UnicodeChart'), 20)
cs

그럼 이만!

 

 

 

 

댓글