In application I create some instances of the same form (all windows attributes besides handle are the same) and work with them independently. During session form changes own title depending on context, I need to wait title changing after certain operations in form.
Next code, don't wait and get window immediately before title changed:
w = app.window(handle = handle, title_re = '...', class_name='...')
w.wait('ready', timeout = 2)
due to work features of function find_elements()
:
if handle is not None:
return [backend_obj.element_info_class(handle), ]
So, what the best solution for it?
P.S. some forms I need to speed up execution, it's important
Of course I can use next code:
def check_state():
windows = app.windows(title = '...', class_name='...')
for w in windows:
if handle == w.handle:
return(True)
return(False)
pywinauto.timings.wait_until(5, 0.5, check_state, True)
Is it the best solution or probably I skipped something else?
Yes, function timings.wait_until(...)
is good enough for this purpose. Methods .wait()
and .wait_not()
are limited to a window specification only. wait_until
is generic one.
Also search criterion found_index=i
can be useful in .window(...)/.child_window(...)
specification.