Need help with 'The window was destroyed during method execution'
I have tried various methods to target the checkbox in question (see below), tried both 'Click' and 'ClickChecked' methods (both are listed in Object Spy > Methods tab).
The browser is terminated at the beginning of the script make sure there are no instances of the browser running. Also, the Mouse movement delay under Project Properties is set to 0.
The code I am using -
let page = Sys.Browser(iexplore).Page("*/THC*"); let panelUsers = page.FindChildEx("idStr", "Users", 10, true, 10000); let chkRegression = panelUsers.FindChildEx("ObjectIdentifier", "UsersGrid_checkbox_Regression", 15, true, 10000); chkRegression.Click();
Got an error: 'The window was destroyed during method execution.'
Also, tried the following and got an error - 'TypeError: Cannot read property 'Click' of null'
aqUtils.Delay(300); let chkRegression = panelUsers.QuerySelector(".panelUsersCheck"); //or let chkRegression = panelUsers.QuerySelector(#jqg_UsersGrid_*)
Using following did not help either.
if (chkRegression.Exists){ chkRegression.Click(); } else { Log.Warning('Unable to find chkRegression'); }
Thanks.
Dave
What it sounds like is that, while the FindChildEx returns the object, something is still process on the page that destroys and, potentially, recreates the object. This is a standard problem in the world of Ajax and other such client side code execution. You might need to add different code to detect that the page has completely refreshed, including all client side execution, before you do your Find calls.
What the error means, FYI, has to do with object handles. So, the FindChildEx returns an object with a handle... that handle gets destroyed and a new one gets created. So, to us, the user, it all looks seemless. But behind the scenes, the tool no longer has a hook into the object. So, you need to make the tool wait longer before doing the FindChildEx. A hard coded delay is a start.... but 300 milliseconds is probably not long enough. I'd actually try that method but bump the delay up to 30000 milliseconds JUST as a diagnostic to make sure that waiting longer will fix the problem. If a longer delay fixes the problem, then you need to make your code "smarter".