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 end this CBT session via code( manually I know how to stop this from crossbrowsertesting site)
I want to stop the session in the place I have marked in RED below
def CBT_LaunchCode(server,capabilities,url):
Browsers.RemoteItem[server, capabilities].Run(url)
if (Sys.Browser().BrowserWindow(0).Exists):
Log.Message("Continue with the test")
else:
#Stop CBT instance here via some code
Browsers.RemoteItem[server, capabilities].Run(url) #then reconnect here
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!