Q: Browser Loop // Data Driven Browser Loop
- 8 years ago
Unfortunately, there's not a way to do precisely what you want. The Browser Loop operation is like a for loop or while loop operation. It's just the start of the loop. You then need to add "child" operations under it that execute within the loop. So, you can't drop a "Run Script Routine" operation and have it operate as the top end of a loop operation.
To do EXACTLY what you want, you'd have to restructure your project where you would have a single script as a test item in your project. That script would include your script equivalent of the browser loop which could be coded to include your list of regular and virtual browsers. Within the loop, you would call your Keyword tests in the desired order, those keyword tests would then, in turn, call your script routines.
Just a rough idea, let's say you keep your list of browsers to run in a CSV file with the browser name and a boolean for if it's a regular or virtual browser. So, I'd do this kind of thing:
function runAllTests(){ var browserLoopData; browserLoopData = DDT.CSVDriver('C:\test\loopdata.csv'); while (!browserLoopData.EOF){ if (browserLoopData.Value('IsVirtual') == 'Y') { VirtualBrowsers.Item(browserLoopData.Value('BrowserName').Run(); } else { Browsers.Item(browserLoopData.Value('BrowserName').Run(); } KeywordTests.Test1.Run(); KeywordTests.Test2.Run(); browserLoopData.Next(); } }
And then make this your only test item in your project.
- 8 years ago
Another option for this would be to have all Projects have a table variable with the names of the browsers to run and each KWT always loops this this table from start to end, passing the browser name to an open browser function (if you're testing responsiveness you could also set your browser sizes with this).
Then at run time (use an on test start event handler) you can update the table variable to only include the browsers (and / or sizes) that you would like to run.
With this option, you still have all of the test cases in KWT format for the formating and ease of use for non-scripters and you do not have to add new KWTs to your loop function every time, and each test will loop through browsers as opposed to each browser looping through all tests (personal preference for setup).