Modeling a Script
After creating a Script you can model it by using variables to more accurately simulate the behavior of real users when the Test that references the Script is run.
The following example documents the procedures involved in modeling a user name and password to enable the simulation of multiple Virtual Users when a Test is run.
Modeling a Script involves:
Note: Use the SCL Reference Guide if you need help using Script Control Language. There is an on-line copy shipped with the Script Modeler Module, or you can download or view it from OpenSTA.org.
Open a Script from Commander
- In the Repository Window within Commander, double-click Scripts, to expand the directory structure.
- Double-click on the Script FINDBYNAME.
- Script Modeler is launched, opening the Script you have previously recorded.
Create and Apply Variables
- With your FINDBYNAME Script open, click Variable > Create.
- Shortcut: Click in the Variable Toolbar.
- In the Variable Creation dialog box, enter a name for your new variable. In this example the name is USERNAME.
- Note: The name you give must be an OpenSTA Dataname.
- Select the Scope of your variable.
In this example the selection is Script.
- Note: The scope of a variable relates to which Virtual Users and Scripts can make use of the variables you create.
- Select the Value Source of your variable.
In this example the selection is Value List.
- Select the order in which the variable values are selected when a Test is run.
In this example the selection is Sequential.
- Select the data types of the variable.
In this example the selection is Character.
- Click Next when you have made your selections.
- In the Value List dialog box you need to enter the variable values, or names that will represent the Virtual Users you need when the Test is run. In this example there are five values or user names entered manually within the Value List dialog box, in this example they are:
- phillip, allan, david, robert and donna.
- Click Add Value and enter the first name.
- Repeat this process until you have entered all the values.
- Click Finish when the setup process is complete.
- Repeat this process to create the PASSWORD variable, which your five Virtual Users will need in order to access the Which US President? Web site.
Note: This Web site requires a password to be the reverse spelling of the login name.
- The variables you have created are represented as text strings within the Definitions section of the Script, as illustrated below:CHARACTER*512 USERNAME ( "phillip", "allan", "david" & , "robert", "donna" ), SCRIPT CHARACTER*512 PASSWORD ( "pillihp", "nalla", "divad" & , "trebor", "annod" ), SCRIPT
- The variables are now ready to be substituted for the original login identity recorded in the Script.
Obviously something happened here ... there are no instructions on how to then make use of these vars in your script :-(
Please Check this documentation for help on using the variables
- Select Capture > Syntax Check or click , in the Capture/Replay Toolbar, to compile your Script.
- Compilation results are reported in the Output Pane. If compilation is unsuccessful, you may need to re-model to resolve the problem.
- It is a good idea to replay the Script to check the activity you have recorded before you incorporate it into a Test.
Select Capture > Replay or click , in the Capture/Replay Toolbar. The replay activity is displayed in the Output Pane.
- Click , to save your Script, or click File > Save.
The Script is now successfully modeled and ready to be incorporated into a new Test. Go on to the next section for information on creating Collectors, which are used to monitor and collect performance data during a Test-run.
Next Section: Creating Collectors
Back to Contents