이번편에서는 Python-UIAutomation-for-Windows의 library에서 필요할 만한 기능을 설명한다
이번편 부터는 자동화 테스트 시나리오를 작성하고 그 시나리오에 맞춰서 스크립트를 작성해본다.
추후에 디테일하게 개인적으로 생각하는 자동화 테스트 시나리오에 필요한 요소를 따로 설명할 예정이다
이번편에서는 간단하게 테스트데이터, Step, 기대결과요렇게만 활용할 예정이다
GIT GUI툴을 통해서 Clone받기간단하게 뚝딱 뚝딱 완성

gitguit_test.py로 파일이름에 python test코드는 파일 이름에 test를 입력한다
마우스 우클릭 → GO TO → Test 클릭Run Icon클릭


os를 통해서 수행한다 # Clone폴더 값 정의
clone_folder = "C:\\dev\\git\\UIAutomationExample"
# Clone 대상 폴더가 존재할 경우 폴더를 지운다.
import os
if os.path.exists(clone_folder):
os.system('rmdir /S /Q "{}"'.format(clone_folder))
# Clone 대상 폴더가 없는지 확인한다.
if os.path.exists(clone_folder):
assert False, "clone대상폴더가 지워지지 않음"검색하려면 여기에 입력하십시오.인 걸 확인할 수 있다.
import uiautomation as auto
auto.ButtonControl(searchDepth=3, Name='검색하려면 여기에 입력하십시오.').Click() gui입력 후 파일 실행 아이콘을 inspect로 확인하면 왼쪽의 tree에는 나타나지 않는것을 확인 할 수 있다. 이럴때는 depth속성을 좀 많이 주면 element가 찾아지는 경우가 있다. auto.TextControl(searchDepth=10, Name="Git GUI").Click()
import uiautomation as auto
# 검색영역 클릭하기
auto.ButtonControl(searchDepth=3, Name='검색하려면 여기에 입력하십시오.').Click()
# 검색영역에 값 입력하기
auto.EditControl(searchDepth=3, Name='검색 상자').SendKeys('git gui')
# Git GUI아이콘 클릭하기
auto.TextControl(searchDepth=10, Name="Git GUI").Click()
# Git GUI가 정상적으로 수행되었는지 확인
auto.WindowControl(searchDepth=1, Name="Git Gui")
Clone Existing Repository을 크릭하려고 하였으나 해당 객체는 inpect가 되지 않고 바로 상위의 객체만 조작이 됨. 이런 경우 해당 객체를 클릭할 수 없어서 계획을 수정해서 상단의 메뉴를 통해서 clone을 수행한다
# 상단 메뉴를 통해 Clone을 수행
auto.MenuItemControl(searchDepth=8, Name="Repository").Click()
auto.MenuItemControl(searchDepth=8, Name="Repository")
# inspect를 통해서 menu의 AutomationId가 48이므로 이를 활용
auto.MenuItemControl(AutomationId = "48").Click()
# 아쉽게도 해당 APP은 "Clone Existing Repository"에 대한 정보를 확인할 수 없는 앱이어서
# 이후 동작으로 확인할 수 밖에 없다. 앞선 스크립트에서 정상적으로 글씨가 있는지 확인 하고 싶었으나 inspect결과에서 보면 해당 화면의 값을 확인 할 수 있는 속성이 없고,ClassName이 TkChild인 것만 확인 가능하다. 이럴때는 TkChild인 ClassName의 Index로만 객체를 조작 할 수 있다.
# Source location 및 Target Directory 값 정의
source_location = "https://github.com/jjunghyup/UIAutomationExample.git"
target_directory = "C:\\dev\\git\\UIAutomationExample"
# Source Location값과 Target Directory값을 입력한다.
auto.PaneControl(ClassName="TkChild", foundIndex=14).Click()
auto.PaneControl(ClassName="TkChild", foundIndex=14).SendKeys(source_location)
auto.PaneControl(ClassName="TkChild", foundIndex=11).Click()
auto.PaneControl(ClassName="TkChild", foundIndex=11).SendKeys(target_directory)
# 값이 정상적으로 입력된다.
# 값을 Clipboard에 복사하고 붙여넣기 식으로 확인이 가능하지만 해당 내용은 이후에 작성 예정
# Clone 버튼을 클릭한다.
auto.PaneControl(ClassName="TkChild", foundIndex=18).Click()
# Clone 대상폴더가 존재하는지 확인한다. 10초 동안 확인한다.
result = False
for i in range(0, 10):
if os.path.exists(clone_folder):
result = True
assert result, "clone대상폴더가 존재 하지 않음"
스크립트 url : https://github.com/jjunghyup/UIAutomationExample/blob/master/gitgui_test.py
안녕하세요, 좋은 글 감사합니다.
혹시 Window 프로그램에서 특정 버튼을 선택하기 위해 inspect.exe로 확인해보니 Name = ""로 되어있다면, 해당 버튼을 찾을 수 있는 방법이 있을까요? AutomationId 같은 값으로 확인할 수 있나 시도해봤는데 동작하지 않더라구요 ㅠㅠ