Forum Discussion

marinb's avatar
marinb
Contributor
8 years ago

How to rerun a test suite with a different browser?

Currently, my test scripts contain the following loop:

 

function testScript01() {

   for (let eachBrowser of supportedBrowsers) {

      startBrowser(eachBrowser);

      testStep01;

      testStep02;

      etc etc;

   }

}

 

i.e. simply repeating the test for each browser we have added to our supported browsers list.

However, I 'd like to know if this can be done in a smarter way?

 

For example, on a much higher level: The project test items. I notice, there is a 'count' column where you can specify how many times a test item will be repeated.

Is there a way to read the iteration number of the current test or specify parameters per iteration? That way, I can simply extract the browser to use for the specific test by using startBrowser(supportedBrowsers[iteration number]) or set the browser via a parameter for that iteration.

 

 

 

 

8 Replies

    • marinb's avatar
      marinb
      Contributor

      That is not an option at the moment (but a very cool bit of functionality nonetheless)

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What you have is, actually, aside from using CrossBrowserTesting, the best way of doing what you want to do.

    • marinb's avatar
      marinb
      Contributor

      So does that mean that adding a Project.TestItems.CurrentIteration would be a very nice property to have? Since we already have a CurrentItem...

       

      Or even better, add a supported browsers variable to test items and have a checkbox 'repeat for each browser'.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Honestly, I don't see the need to go that route.  You're running the loop through all your supported browsers and executing all your tests.  Doing anything else I think just muddies the waters, IMO.

         

        What do you intend to "improve" by making such changes?  Perhaps with an understanding of that goal, I'll understand better what you are looking to do.