Ask a Question

TestedApp.Close doesn't close the application

Oferv
Super Contributor

TestedApp.Close doesn't close the application

Hi,



when trying to close the AUT using the following method http://smartbear.com/support/viewarticle/12380/ th application doesn't close.

anyone know why?



Thanks
15 REPLIES 15
tristaanogre
Esteemed Contributor

I tried the following: 



function meh()

{

    var MyApp = TestedApps.NOTEPAD.Run()

    Delay(1000)

    MyApp.Close()

}




Worked just fine.  How are you implementing? Could you post the code you're using?  Are you getting any errors?

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
Oferv
Super Contributor

Hi Robert,



that doesn't work.any other ideas?



thanks
tristaanogre
Esteemed Contributor

As I said, that worked fine for me.. I'm running TestComplete 8.60 and there are no problems.



So, the question is still, how have you implemented this concept?  Please post your code.. include any information such as the kind of application you're testing (web, desktop, etc) and any error messages you're getting.  



See, I say it works, you say it doesn't, somewhere there's something wrong.  If you can post your code with that information, we can figure out, from there, what's going wrong.



I've also done the following:





function meh()

{

    var MyApp = TestedApps.NOTEPAD.Run() //Notepad has a count value of 3

    Delay(1000)

    MyApp.Close()

    TestedApps.NOTEPAD.Close();

}




This closes all three... however, the last line DOES generate a warning saying it couldn't find one instance...but that is expected since I closed one of the three individually.



So... the methodology from the help article is working using the simple "NOTEPAD" example as given... so, the problem is probably within the application you're using or how you're implementing it.

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
Oferv
Super Contributor

Sure Got you,

the AUT is a desktop application



here is the code:



main unit:


//USEUNIT InvokeAUT

//USEUNIT CloseAUT





function Main()

{

InvokeAUT["Invoke"]()

CloseAUT["Close"]()

}





InvokeAUT unit:


//USEUNIT CloseAUT





function InvokeAUT()

{

if(Aliases["AUTDesktopMainWindow"]["Exists"]) 

  CloseAUT["CloseAUT"]()

//Loading the AUT

TestedApps["AUTDesktop"]["Run"]()

//Check that the AUT loaded properly

if(Aliases["AUTDesktopMainWindow"]["Exists"])

  {

  Log["Message"]("AUT was loaded properly")

  return

  }

else

  Log["Warning"]("AUT wasn't load properly,script aborted")  

}






function CloseAUT()

{

TestedApps["AUTDesktop"]["Close"]()

//Check that the AUTclosed properly

if(!Aliases["AUTDesktopMainWindow"]["Exists"])  

  Log["Message"]("AUT was closed properly")  

else

  {

  Log["Warning"]("AUT wasn't closed properly,script aborted")

  return 

  }

}












tristaanogre
Esteemed Contributor

I replaced the AUT stuff with the windows calculator... works fine. 



Is your application running when you run the invoke?  Is the process present in memory?  Do you have more than one copy present in memory?  Are you getting error messages?  

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
Oferv
Super Contributor

answers to your questions:



Yes, although it takes around 10 seconds for it to invoke

Yes

No

I'm getting warning message in the Test Log file:


Type Message Time Priority Has Picture Link

The application "C:\Program Files (x86)\xxx\AUT\AUTDesktop.exe" got a command to close, but it is still running, though the default timeout has expired. 16:02:03 Higher



Thanks
Oferv
Super Contributor

Hi Robert,



it's not nice to say but when i restarted TC it seems to work fine.weird isn't it

can you think of something that can cause that?



thanks for the help 🙂 appreciate it
tristaanogre
Esteemed Contributor

When you normally close your application, does it take a long time for it to actually complete the close process?  Is there user interaction necessary on close?



The problem at this point seems to be related to how your application processes the close command or, even, what it's doing at start up.  It could be that when you are trying to close it, you're not waiting long enough to let it complete the startup process.  Try putting something like a Delay(60000) between the Invoke and Close to see if, after you wait a while, the close command works.

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
itvrdeich
Contributor

When I close my own tested application, it closes the program but the process is still running. I believe Test Complete holds a handle on it and thats why the process doesnt end.

I force quit my program from task manager and windows error reporting reports that there was an appcrash.

I believe that you guys are using hooks in Test Complete and that the library called tcuihook.dll could be the culprit.

Pretty problematic at my workplace.
cancel
Showing results for 
Search instead for 
Did you mean: