cancel
Showing results for 
Search instead for 
Did you mean: 

Getting "The window was destroyed during method execution" error in TestExecute on windows server

SOLVED
Highlighted
Occasional Contributor

Getting "The window was destroyed during method execution" error in TestExecute on windows server

When trying to run TC script on Windows server 2016 getting error - The window was destroyed during method execution" after the url opens in chrome browser.

Script runs fine in my desktop but in server it returns this error.

Can anyone help?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Hi @Nikolayev , maybe you could consider updating first? I see that you are using not the latest version.

If this doesn't help, contacting support would be the best next step.


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

16 REPLIES 16
Highlighted
Community Hero

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

That error, in my experience, is usually something having to do with an un-seen page refresh and, therefore, a timing issue... TestComplete has identified the object and so the action (click, keys, etc) is attempted but, in that split second, the object is destroyed and recreated in memory (page refresh, etc) so that the previous memory handle is no longer valid and so the click, keys, etc., generates the error.

 

You will need to examine the code around that particular situation and see if you can make it "smarter" to determine if the page has been properly loaded, all client-side scripts have completed, etc., before proceeding on to the UI action.

The reason why it works on yours and not on the other machine, as mentioned, is most likely timing.  The automation is running at "full speed" but on that server box there may be other factors that are slowing down the application execution so that it can't "keep up" with the automation speed.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Thanks  

I understood the reason why I am getting the error but how should I resolve this?

I tried adding aqUtils.Delay(5000, "Delaying Test Run"); to delay execution and wait for page load but still getting same error. 

Any other solution recommended by you?

Highlighted
Community Leader

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Does the error just happens after .navigate or .toUrl call ? A sample of your call please and the log concerned

Does the error is systematic on WS2016 ?

Does the error happens on other browser on WS2016 ?

Un sourire et ça repart

Highlighted
Occasional Contributor

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

The error happens after navigating to url. In IE, it works fine. Seeing this issue in chrome only, before clicking on link, it fails.

Below is my script - 

function Test2()
{
Browsers.Item(btChrome).Run("url");
aqUtils.Delay(10000, "Delaying Test Run");
Aliases.browser.pagePita3.navNavLeft.linkAccountInitialization.Click();
Aliases.browser.pagePita.Wait();
Aliases.browser.BrowserWindow.Close();
}

Highlighted
Community Leader

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Could you try without Aliases ?

 

Un sourire et ça repart

Highlighted
Community Hero

Re: Getting "The window was destroyed during method execution" error in TestExecute on win


@Shehnaz wrote:

The error happens after navigating to url. In IE, it works fine. Seeing this issue in chrome only, before clicking on link, it fails.

Below is my script - 

function Test2()
{
Browsers.Item(btChrome).Run("url");
aqUtils.Delay(10000, "Delaying Test Run");
Aliases.browser.pagePita3.navNavLeft.linkAccountInitialization.Click();
Aliases.browser.pagePita.Wait();
Aliases.browser.BrowserWindow.Close();
}


In the code above, at what point do you get the error?

 

Also, note that Chrome does, sometimes, take longer to resolve a page after being launched since it does a "check for updates" immediately upon running and that can take a few moments.  Additionally, there may be extensions, etc., in chrome that need to start up and check for updates as well.  So, you have a 10000 hard coded delay there.  That MIGHT not be enough for Chrome on startup.   I'd actually do a "Wait" on the page after launching the URL and set the timeout to something like 120000 just to make sure that you have the whole page up.  So, modified code:

 

function Test2()
{
Browsers.Item(btChrome).Run("url");
Aliases.browser.pagePita3.Wait(120000);
Aliases.browser.pagePita3.navNavLeft.linkAccountInitialization.Click();
Aliases.browser.pagePita.Wait();
Aliases.browser.BrowserWindow.Close();
}

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Hi Robert,

 

Thank you for sending modified code. But unfortunately, it didn't work , still getting same error after the page loads and before clicking Account Initialization link.

 

See attached TC logs.

 

 

 

 

 

Highlighted
Community Hero

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Could you give more of the log?  From what I'm seeing, there's a navigation line above the error... so... are you SURE it's happening there and not on the BrowserWindow.Close?  Double click on the error line should take you to the line of code generating the error.

Also... I suspect that the code you posted here is NOT exactly what is executing.  Is it possible for you to post the actual code generating the error?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Leader

Re: Getting "The window was destroyed during method execution" error in TestExecute on win

Please make a try plain script (without aliases)

Un sourire et ça repart

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors