Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
6 years ago

run all browsers in loop and only stop execution for current browser on error

Is it possible to make this?

 

Right now my tests run in a loop on 8 browsers and it is very bad for the test if it stops the execution for the whole test, if there is an error in edge (which is the first browser it usually starts) and all other browsers would work.

 

Is there some kind of trick to stop the Browser Loop for the Browser where the error occured and start over from the Browser Loop Top with the next browser?

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed 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.

    • Lagencie's avatar
      Lagencie
      Frequent 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

      • tristaanogre's avatar
        tristaanogre
        Esteemed 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.

    • Lagencie's avatar
      Lagencie
      Frequent 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