Shwetha Mahadik
Shwetha Mahadik

Reputation: 61

how to wait until the required window title appers in pywinauto

How to wait until the required window title to be appers using pywinauto?

I have to wait for required window title, once I found that window title have to do some action on that window. How I can do this?

Upvotes: 2

Views: 8014

Answers (2)

Shwetha Mahadik
Shwetha Mahadik

Reputation: 61

Ok now i got how to use WaitUntilPasses this method I was trying below small script.

app = pywinauto.Application() 
app.start('Notepad') 
Win = "Untitled1.txt" + "-" + "Notepad" 
window = pywinauto.timings.WaitUntilPasses(20, 0.5, lambda: app.window_(title=Win))
app.Untitled1.MenuSelect('Help -> About Notepad')

Here after opening the notepad within 20sec i saved the notepad with Untitled1.txt and after saving the notpad title of the notepad shown like "Untitled1.txt - Notepad" So in the above script am waiting for the same title and once i got the same title trying to select the menu option in that notepad but after 20sec am getting here am getting timeout error.

Upvotes: 0

SWAPYAutomation
SWAPYAutomation

Reputation: 693

The easiest way is to use pywinauto.timings.WaitUntilPasses

app = pywinauto.Application()
app.start('calc')
window = pywinauto.timings.WaitUntilPasses(10, 0.5, lambda: app.window_(title=u'About Calculator'))
#run About manually in 10 seconds
<pywinauto.application.WindowSpecification object at 0x02DD0DB0>

Upvotes: 1

Related Questions