Toolboxcategory cloud |
ViewsPersonal toolsUnderstanding Repository VariablesFrom Seapine LabsRepository variables can help you test dynamic attributes of Windows and Web applications. Repository variables, which are defined in the application repository for each version, can be used in any scripts recorded or run against the application. During playback, any instance of a variable is replaced with the default value set for the variable or the value selected when playback starts. The primary benefit of using repository variables is that you can maintain a reusable suite of test scripts without spending extra time modifying or creating new scripts every time an application changes. Repository variables also allow you to manage and access dynamic test data without maintaining multiple data sources. This article describes common uses for repository variables, where variables can be used, how variables are used during recording and playback, and how to create variables.
[edit] When to use repository variablesUse repository variables if you have multiple scripts that test the same data and the data changes based on application conditions and inputs. Dynamic data may include input values, URLs, window names, or application text. The following examples describe common uses for repository variables. [edit] Web sites hosted on multiple serversYou may need to run the same scripts against multiple Web servers, such as development, test, and production servers. You can create a repository variable that contains each server address as a value and set the variable to prompt when recording or playback starts so users can select the address to use for the session. You can also use the variable in the URL to open the Web page. When you create a new Web application, you can automatically create a URLROOT repository variable. The URLROOT repository variable stores Web server addresses so you can easily run scripts against multiple servers. [edit] Applications with multiple login credentialsAn application may include functionality that is only accessible when a specific username and password is used. Instead of maintaining multiple login scripts or modifying scripts to change static username and password values, you can create username and password variables. You can set the variables to prompt when recording or playback starts so users can select the appropriate login values. [edit] Applications with dynamic controlsDynamic applications may have controls with properties that change frequently, such as window names. QA Wizard Pro may use these properties to locate controls during playback. If the expected value of a property selected as search criteria does not match the application during playback, scripts fail. To avoid this, you can create a repository variable for the dynamic property and specify the variable as the expected value in the application repository. [edit] Where to use repository variablesYou can use repository variables in scripts, window and control expected values in the application repository, and Web application startup URLs. [edit] In scriptsRepository variables are commonly used in scripts to replace static values in statements. For example, an application has a LOGIN_NAME repository variable and you want to replace any instance of a static username value in scripts with the variable name. In the GUI statement editor, you can select Expression as the value type and enter the variable name as the expression. The following example shows the LOGIN_NAME variable used in the Type Text statement. In Text View, you can replace the static value with the variable name. The following example shows the LOGIN_NAME variable used in the Type Text statement. Window ("Login").Control("Username").TypeText(LOGIN_NAME) You can also assign values to repository variables in scripts. In the GUI statement editor, use the Assignment statement. In Text View, enter the variable name followed by an equals sign and the value, which can be text, an expression, or a value from an associated datasheet. For example: LOGIN_NAME = "Administrator" Note: You can use script variables to override repository variables during playback. If a script variable and repository variable have the same name, the script variable value overrides the repository variable value. After playback, the repository variable maintains its default value. You may want to establish a naming convention for repository variables to make sure that duplicate names are not created. [edit] Expected values for windows and controlsYou can use repository variables in the expected values used as search criteria to locate windows and controls during playback. For example, the URL for a hyperlink on a Web page changes based on the server address. If a property used as search criteria includes the URL, scripts will fail because the expected value does not match the actual Web page value. You can replace the static URL with a repository variable so QA Wizard Pro can successfully locate the hyperlink during playback. The following example shows how the URLROOT repository variable is used instead of the static server address in the Href property. [edit] Web application startup URLsIf you add the URLROOT repository variable when you add a Web application, it is automatically used in place of the static URL in the application startup information. If you later decide to use a repository variable instead of a static URL, you can modify the URL in the application properties. Right-click a version and choose Properties. Replace the static portion of the URL with the repository variable name and use percent signs at the beginning and end of the name to indicate that the value is a variable. The following example shows the URLROOT repository variable used in a startup URL. [edit] How repository variables are used during recordingRepository variables are only used during recording if the Auto-Record Substitution option is selected for the variable. Auto-record substitution automatically replaces any instance of the variable value in the script with the variable name. Any instances of the variable value in expected values for new controls captured during the recording session are also replaced with the variable name. For example, if you use the URLROOT repository variable with a default value of http://www.seapine.com and the Auto-Record Substitution option is selected for the variable, all instances of http://www.seapine.com are replaced with %URLROOT% during recording. You should only use auto-record substitution to replace unique values, such as Web server addresses. If the value is not unique, you may unintentionally replace the wrong value in scripts and the repository, which can cause scripts to fail. [edit] How repository variables are used during playbackDuring playback, the default repository value or a selected value is used for each instance of the variable name. For example, if the default value for the URLROOT variable is http://www.seapine.com, any instance of URLROOT in the script or repository is replaced with http://www.seapine.com. Repository variables include a Prompt option, which provides flexibility to preset variable values when recording or running scripts. If the variable is set to prompt, the Enter Variable Values dialog box opens when recording or playback starts. You can use the default variable value displayed in the dialog box or enter or select a different value. If you use a different value, it is set as the new default variable value. The following example shows three variables and their default values in the Enter Variable Values dialog box. [edit] How to create repository variablesYou can create the URLROOT repository variable to store Web server addresses when you create a new Web application or create a variable for any purpose in the application repository. [edit] New Web application—URLROOTWhen you create a new Web application, the URLROOT repository variable is created by default. The variable value is the root URL for the server that hosts the application. The following screenshot shows the URLROOT repository variable created for a site. The URL used to open the site is www.wysicorp.com/products. When the application is created, the URLROOT variable replaces the server portion of the URL in the application startup information. The value stored in the repository will be %URLROOT%/products. Note: By default, the URLROOT repository variable is set to use auto-record substitution and is not set to prompt before recording or playback starts. [edit] In the application repositoryYou can also create repository variables in the application repository.
|
|


