In my current work, I need to automate tests for a 3rd party Windows based logic programming app. 1) I want to start an application, 2) Specify the window to work on, 3) Find all the controls and properties 4) Finally get the output values from the controls Can someone please help? Thanks!
Here is my code:
#import the pywinauto.application module
from pywinauto.application import Application
# create an applicaiton instance and execute the application
app = Application(backend="uia").start('calc.exe')
# creating window specification
dlg_spec = app.window(title='Calculator')
# window lookup to deal with the window/control
dlg_spec.wrapper_object().minimize()
dlg_spec.minimize()
# Printing the control identifiers
app.Properties.print_control_identifiers()
I get TimeoutError and ElementNotFoundError (on Line 4)
Calculator is a little bit complicated case for now (yay!). Windows 10 calc.exe
implementation creates another process. I can say more: its UI controls hierarchy doesn't fit into bounds of one process (really): there are few processes for one app. We have plans to detect new spawning process while starting an app, but it's NOT in pywinauto yet. But going deeper into .children()
or .descendants()
follows the whole hierarchy across process bounds (the only important thing: who is parent).
Current example for calc.exe
looks so (see latest win10_calculator.py in the repo):
from pywinauto import Desktop, Application
app = Application(backend="uia").start('calc.exe')
dlg = Desktop(backend="uia").Calculator # window specification
dlg.type_keys('2*3=')
dlg.print_control_identifiers() # this is also window spec method
dlg.minimize()
# minimized window needs some tricks to find it and restore
Desktop(backend="uia").window(title='Calculator', visible_only=False).restore()