Reply
Highlighted
Contributor
Posts: 31
Registered: ‎03-16-2017

If Browser throws Exception

I am using the function If Browser to check which browser is running.

 

Problem is that during development phase it always throws the exception that no browser is running - because i dont start the browser, but its already open.

Is there a way to set the browser variable just as a dummy, because from what i understand testcomplete searches for the object anyways and not on the set variable during testrun.

 

when i make Run Browser before the If Browser works - if i just have an open browser it doesnt

Posts: 4,208
Topics: 36
Kudos: 1,472
Solutions: 304
Registered: ‎11-30-2009

Re: If Browser throws Exception

The if-browser operation depends upon TestComplete being in control of the browser execution.  Run Browser or Navigate actually sets the Browsers.CurrentBrowser property to indicate what is the current browser being used by the current keyword test.  So, if either of those operations isn't run, TestComplete doesn't know which of the potentially many browsers that could be open in your Windows environment to check.  You should, at least, use the Navigate method before an "If Browser" call during your development process to signal what browser to use.


Robert Martin
[Community Expert Group]
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.

Extensions available
Community Leaders Program
Contributor
Posts: 31
Registered: ‎03-16-2017

Re: If Browser throws Exception

well, thanks for the answer, but its still a strange behaviour, especially because testcomplete isnt using the browser it opens himself anyways - but searches over all open browsers during execution

Posts: 4,208
Topics: 36
Kudos: 1,472
Solutions: 304
Registered: ‎11-30-2009

Re: If Browser throws Exception

If Browser checks that property... well documented... so, if that property is not set, then If Browser won't work.  The only way to set that property is via either the Run Browser or Navigate operations.

 

While you are correct in TestComplete will operate against any browser open when opened manually, that operation has a very specific use in the feature set for testing across multiple browser types.  It's purpose is so that, if you are running a test case in a browser loop or parameterized web test case, you can control different behaviors if the browser currently in use is a particular browser.

 

So, for your purposes, in order to develop against that, at least for the short term, add either Run Browser or Navigate before your If Browser call.


Robert Martin
[Community Expert Group]
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.

Extensions available
Community Leaders Program
Try QAComplete Now