As stated the use of TransactionBegin and TransactionEnd can be used in the script to ensure that a user logs on only once before executing the transaction part of the script multiple times then finally logs off only once. This approach makes script development and testing a little more simple than with modular scripts. The benefit of only having to maintain one log and one logout can be retained by using in Include file and referencing the subroutines in the transaction script (remembering to remove the call to them before using the script as part of a scenario). That said most of time it’s easy just to use the script as it was when it was recorded if the login steps are straight forward.
TransactionBegin and TransactionEnd section of the script can be set as part of the capture process using the button circled in the screenshot below. Please note there can only be one transaction section per script. All the button is going to do is to add the TransactionBegin statement when it is pushed and add the TransactionEnd statement when it is pushed again. These commands can of course be added manually. It is important to understand the user session when using these commands. For example when testing a .Net Microsoft application that stored session state in the client with it’s __VIEWSTATE parameter you must ensure that that parameter will be valid upon the second iteration of the script.
The image below explains the flow of the script when multiple iterations are requested.
The transactions are controlled in the Job scenario in AgileLoad Center in a similar way to that of the approach with modular scripts. The only difference is the absence of the login and logout scripts (those actions are of course now held in the script of course).
In the screenshot below the BuyBook script now has the TransactionBegin and Transaction End command in the script. In this scenario it will login once, buy 5 books and logout once for each scenario execution.
A useful way to test the positioning of the BeginTransaction and EndTransaction statements is to set a number of replay iterations in AgileLoad Test Center. We recommend that you try at least three. The number of iterations can be adjusted in the replay options menu item: Options -> Replay. See the folowing screenshot for an example.