Lyle Lacey
Lyle Lacey

Reputation: 31

Can Pywinauto Track or Log Error with an Application?

Is there any way to track or log error in Pywinauto (eg a pop-up window does not appear, etc.) ? I am trying to track if a window opens correctly or not. I am also trying to verify values in an Excel Worksheet. Is this possible ? Oh! Yes, I am a newbie to Python and Pywinauto. Thanks for your assistance !!

Upvotes: 0

Views: 545

Answers (1)

Vasily Ryabov
Vasily Ryabov

Reputation: 9991

For working with MS Excel I would recommend using standard win32com.client module (it's included into ActivePython, or pyWin32 extensions can be installed by pip install pypiwin32 for example). Almost every Microsoft application has nice IDispatch COM interface. By the way standard docs example shows MS Excel usage. ;)

For handling window opening pywinauto contains .Wait('ready') method for the window specification. So something like that should work or raise an exception in case of failure:

app.MainWindowTitle.Wait('ready') # 'ready' == 'exists visible enabled'
# or
app.Window_(title_re='^some regular expr - .*$', class_name='#32770').Wait('visible enabled')

You can do the same if the window is closing:

app.SomeDialog.WaitNot('exists', timeout=20) # default or implicit timeout is 5 sec.

If you need bool return value instead of raising an exception, then use methods .Visible(), .Exists(), .Enabled() and .IsActive().

Upvotes: 1

Related Questions