In this blog article, you will learn Desktop app automation testing using Python. Automating a desktop app is not an easy task using open-source tools. In the past, we wrote many blog articles on how to automate desktop applications test cases using White Framework.
However, today we would like to show you how to automate a desktop app using Python.
Required Packages
To automate desktop app, we need the following packages (pyWin32, comtypes, & six). Use the below Pip command to install all the three packages.
pip install pywinauto
Launching An Application
from pywinauto.application import Application app = Application().start("notepad.exe")
Inspecting Elements
You can use anyone of the below listed inspecting tools to write locators.
- AccEvent.exe
- AccExplorer32.exe
- Inspect.exe
- SPYXX.EXE
- swapy-ob-0.4.3.exe
- UISpy.exe
- ViewWizard.exe
- WSEdit.EXE
Locating windows by title
app.window(title="Untitled - Notepad").menu_select("Help->About Notepad")
Locating with regular expression
app.window(title_re='.* - Notepad$')
Finding a window with multiple properties
window = findwindow(title = "Untitled - Notepad", class = "Notepad")
Print Identifiers
Use the below command to print all the identifiers on a window.
app.window(title="Untitled - Notepad").print_control_identifiers()
Other Actions
app.UntitledNotepad.menu_select("File->SaveAs") app.SaveAs.ComboBox5.select("UTF-8") app.SaveAs.edit1.set_text("Example-utf8.txt") app.SaveAs.Save.click()
We explored this library with excitement. Desktop app automation testing using Python library is more user-friendly and the execution is also much faster than other implementations.
Comments(0)