Forum Discussion
5 Replies
- tristaanogreEsteemed Contributor
Inside the loop, add Try/Catch/Finally logic. Make sure you include, in your code in the "Try" section, sufficient handling to accommodate any object identification problems so as to "catch" those errors and move to the next iteration of the loop.
- LagencieFrequent Contributor
ok thanks for the reply.
This would be a rather hard task as our tests already exceed a couple hundreds and adding those try catch function to every single testcase might take a while ... I guess I will take this into account for creating the new tests and I'll see if we can manage the old tests somehow.
Whats the best way of getting to the next browser loop? make a Go to label which you jump to in the try catch? or are there any better attempts- tristaanogreEsteemed Contributor
There's no need... that's what a loop is for.
If you have your code structured like this (this is PseudoCode, not intended to be executed)
for all browsers in BrowserList { try { execute step 1 execute step 2 execute step 3 } catch execption { execute exception handling } finally { execute finalization for loop iteration } }
This will execute the loop for every browser. If an exception is thrown in the "try" code block, "catch" will handle it. "Finally" will execute for every iteration of the loop. Then, if there is still something to loop, it will go back to the beginning of the try section. No need for any "go to".
Now, this will work even for keyword test. Instead of the {}, the blocks are handled by "indentation". So, the try, catch and finally blocks will be all indented under the loop.
- LagencieFrequent Contributor
Had some days now trying to figure out how this could work ... But TestComplete's Try Catch Block doesnt work this way.
It doesn't catch Object Recognition errors.
I have a small keyword test that opens a browser clicks a few elements and checks a table if those elements appear. If object.VisibleOnScreen not appearing, I make a Log Message - Error. But it doesnt jump into the catch block which is declared with Error Code.
This way there is no way to jump to the end and start the new test
Related Content
Recent Discussions
- 2 days agovladd1