I am trying to use waituntilpasses
in pywinauto
to give an application time to open a new window. I have used SWAPY to identify the window details.
For the sake of testing I manually open the sub-window, so the WaitUntilPasses
should see this immediatly, it however does not.
The syntax appears OK as I can find and print the output of find_windows
, as below:
xx = pywinauto.findwindows.find_windows(
title=u'Choose template', class_name='#32770')[0]
print (xx)
This gives a response of 789646
However in my WaitUntilPasses command:
pywinauto.timings.WaitUntilPasses(
20, 0.5,
(pywinauto.findwindows.find_windows(
title=u'Choose template', class_name='#32770')[0]
)
)
It always times out. I cannot see the issue with the syntax, and have tried every permutation I can think of. Any tips would be greatly appreciated.
pywinauto.timings.WaitUntilPasses
waits a function in the third parameter, but not a value of a function execution(in your case).
A fix - convert your checking in lambda function:
pywinauto.timings.WaitUntilPasses(20, 0.5, lambda: pywinauto.findwindows.find_windows(title=u'Choose template', class_name='#32770')[0])
But I favor if you put the checking in a separate function:
def check():
return pywinauto.findwindows.find_windows(title=u'Choose template', class_name='#32770')[0]
pywinauto.timings.WaitUntilPasses(20, 0.5, check) #Important: 'check' without brackets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With