Q: How to wait for an application to open using pywinauto? I have a program that I have automated using pywinauto.
After performing certain actions, the application creates a temp pdf and opens it in chrome browser.
app.dialog["OKButton"].click_input()

MY code waits for sometime for chrome window to appear and then saves the pdf (in chrome) to desired location.
However, when the data is large enough the application takes time to generate the pdf and chrome is not yet opened.
How do I wait for chrome to appear before connecting to the chrome application window.
time.sleep(action_interval)
app.dialog["OKButton"].click_input()
time.sleep(10)
# Chrome
app2 = Application().connect(title="Statement - Google Chrome")       
app2.WindowSpecification.wait('enabled')
time.sleep(10)
app2['Image Statement - Google Chrome'].type_keys("{VK_CONTROL down}"
                                        "S"
                                        "{VK_CONTROL up}", pause=2)

This results into error
ElementNotFoundError: {'title': 'Statement - Google Chrome', 'backend': 'win32', 'visible_only': False}

However, if chrome window appears, this error is not encountered.

A: Please read Waiting for Long Operations chapter in the docs.
In your case it should look so:
# wait flexibly up to 20 seconds
app2 = Application().connect(title="Statement - Google Chrome", timeout=20)

