Forum Discussion

rmaney's avatar
rmaney
New Contributor
5 years ago

How to force stop a CBT run session apart from "Sys.Browser().BrowserWindow(0).Close()"

I am running a few tests on web application. Assume there is situation where remote connection was successful but for some reason browser did not open ( I have observed this situation), now how do I ...
  • sonya_m's avatar
    sonya_m
    5 years ago

    Hi rmaney I see that you got a solution from the Support Team. Let me post it here - 

     

    >>

    ...the issue happens because the error is raised before the Sys.Browser().BrowserWindow(0).Close() call, and the execution of the test item is interrupted according to the project option. This is the expected behavior, TestComplete works in this way. So, you can use the OnStopTest event handler (https://support.smartbear.com/testcomplete/docs/reference/events/onstoptest.html) to close the browser, e.g. like this:

    def EventControl1_OnStopTest(Sender):
        pass
        browser = Sys.WaitBrowser()
        if (browser.Exists):
          browser.BrowserWindow(0).Close()

    <<

     

    Glad that it worked!