I'm trying to automate a software installation. During the installation the PyWinAuto script clicks "Next" to start the installation. It shows a progress bar animation as it installs. Then moves to the next page automatically with a button to click "Done".
I'm trying to figure out how to have PyWinAuto wait until it detects the "Done" button then clicks it. I've reviewed the official documentation and other Stack Overflow questions but have not seen a way to do this. To be clear- the installation windows title is the same throughout the whole process so I cannot just have it check for a new window title's existence.
I realize there are workarounds such as just having it wait 5 minutes every time for it to install but I want to have the maximum amount of reliability.
app = Application(backend='uia')
app.start(programPath).connect(title=programName, timeout=120)
app.TheAppName.Install.click()
app.TheAppName.Next.click() # Starts installation
# TEMPORARY WORKAROUND: Try to click the Done button.
# If it fails then perform a cooldown and try again until maxAttempts is reached.
maxAttempts = 10
cooldown = 60
for i in range(maxAttempts):
try:
app.TheAppName.Done.Click()
except:
print(Exception)
time.sleep(cooldown)
Help would be greatly appreciated. Thank you!
Things I tried:
app.TheAppName.Done.Click(timeout=600)
Why wait
and wait_not
methods are not relevant to your situation? Maybe more precise search criteria could be set:
app.TheAppName.child_window(title="Done", control_type="Button").wait("enabled", timeout=600).click()
Also sometimes there is a hotkey for the button, then the precise title may look like "&Done"
(please double check the exact text). Such kind of window specification performs exact comparison during search procedure.
Magic attribute lookup like app.TheAppName.Done
performs approx. search resistant to few typos, but it has a risk or false detection of another element with similar name. And such magic lookup is typically slow. Using control_type
and exact title makes search much faster. Though for your current case it's not critical.