I am quite new to windows desktop based test automation and also new to python, after spending some good amount of time, pywinauto turned to be an obvious choice to use for windows based application testing using python.
I am using pywinauto to access elements with in a demo app. I have been through related documentation and stackoverflow Q&As, examples on GitHub. This is what I have done
app = Application(backend="win32").start(r"C:\XXX\Bin\XXX.exe")
while not app.Windows_():
time.sleep(1)
if app.window(title="Start Application - XXX 2.3").Exists():
app.window(title="Start Application - XXX 2.3").PrintControlIdentifiers()
The output I get is like this
b'\nHwndWrapper[XXX.exe;;ebf7c21b-5fef-4eb7-a562-3d36735e7519] - \'Start Application - XXX 2.3\' (L668, T45, R1786, B969)\n[\'HwndWrapper[XXX.exe;;ebf7c21b-5fef-4eb7-a562-3d36735e7519]\', \'Start Application - XXX 2.3HwndWrapper[Zen.exe;;ebf7c21b-5fef-4eb7-a562-3d36735e7519]\', \'Start Application - XXX 2.3\']\nchild_window(title="Start Application - XXX 2.3", class_name="HwndWrapper[XXX.exe;;ebf7c21b-5fef-4eb7-a562-3d36735e7519]")'
I have used swapy tool, but that somehow does not provide available controls and using inspect.exe to check the class names etc.
I checked various other ways, like using findwindows, findwindows.find_element for the child window, to somehow click one a button(did not want to use coordinate) and followed by a by tab click, but none that gave me a suitable control, like what I could find using some paid tool like Test Complete.
Wondering, is it possible to do something like below, using pywinauto
Aliases.XXX.HwndSource_mainWindow.mainWindow.leftToolAreaControl.ToolAreaTabItem.TabControl.ClickTab("Acquisition")
At the moment only thing, I can do is open the app, and using the wrapper close or minimize the app.
Any suggestion would be highly appreciated.
Inspect.exe
successfully, you need to usebackend='uia'
. That might be more helpful for modern applications. More details about backends are in the Getting Started Guide. – Vasily Ryabov[u'Size on disk:', u'Size on disk:Static', u'Static4']
. Of course, it should be corrected to comply with attribute name restrictions, saydlg.Size_on_disk_Static.window_text()
. – Vasily RyabovUIAWrapper
can't do attribute access to lower levels. First you need to figure out what is a window specification and how it finds a wrapper. – Vasily Ryabov