Forum Discussion
So, you're doing a WaitWindow on the OK button? Is that what you're checking for existance? Or is it the Setup window before hand? See, WaitWindow waits for the item being looked for in the WaitWindow method, in this case, an object with a class of button, caption of OK, an index of 1, and it ways 2 minutes for it to show up.
If, however, the window that you need to wait for is the setup window, change your code to
if Sys.Process("SWSetup-" + Project.Variables.versionNumber, 2).WaitWindow("#32770", "Setup", 1, 120000).Exists:
Sys.Process("SWSetup-" + Project.Variables.versionNumber, 2).Window("#32770", "Setup", 1).Window("Button", "OK", 1).Click()
else:
Log.Message("TEST")
Note that we're waiting in this for the SetupWindow to exist before we go on to click the OK button. This is the proper usage of WaitWindow. You call it on the parent object of the window you want to wait.
- KSQian9 years agoContributor
Robert's solution will work.
But if the window appears and the Ok button isn't ready to be clicked, then that solution will break.
Here's a pure code take on it. Although in this case I may use the built-in waitwindow function.
const window = Sys.Process("SWSetup-" + Project.Variables.versionNumber, 2).WaitWindow("#32770", "Setup", 1, 120000)
if (window.Exists) {
const button = window.Find(["Button"]) //Edit find with correct parameters
if ( button.Exists && button.Enabled) {
button.Click()
}
else {
Log.Message("window exists, but button cant be clicked.")
}
}
else {
Log.Message("window doesnt exist")
}