Forum Discussion
I inherited a TC project based on VBScript. This is the code:
Set browser = Sys.WaitProcess("iexplore", 1000)
dw((browser.Exists))
browser.Terminate()
browser.Sys.WaitProcess("iexplore", 1000)
'dw' is a "do loop"
Okay. I think I got it working using your recommendation:
Function CloseIE()
Set browser = Sys.WaitProcess("iexplore", 1000)
do while((browser.Exists))
browser.Terminate()
browser.Sys.WaitProcess("iexplore", 1000)
loop
End Function
+++++++
It works, but when iexplore exists it terminate it and then throws an exception "Object Required" with line 3 highlighted as the culprit. [do while((browser.Exists))].
- tristaanogre7 years agoEsteemed Contributor
Change your code to
Function CloseIE() Set browser = Sys.WaitProcess("iexplore", 1000) do while((browser.Exists)) browser.Terminate() Set browser = Sys.WaitProcess("iexplore", 1000) loop End Function
- AlexKaras7 years agoChampion Level 3
Hi,
Just my $0.02...
While Robert posted code that is highly expected to work, I would add one more line to the While loop:Function CloseIE() Set browser = Sys.WaitProcess("iexplore", 1000) do while((browser.Exists)) browser.Terminate() Call browser.WaitProperty("Exists", False, 30000) Set browser = Sys.WaitProcess("iexplore", 1000) loop End Function
The added line will delay for maximum 30 seconds to wait for the browser to be terminated.
The reason for this delay is that it may take some time to the OS to terminate the process and TC may obtain the reference to the process that is under termination and the attempt to terminate the process that is in the unstable state might cause sporadic runtime failures.
Related Content
- 2 years agoianlop
- 11 months agoIso_Yura
- 6 months agomacheshmeh
- 6 years agovthomeschoolmom
Recent Discussions
- 2 days agoGane195