Creating a Variable During Test Case Recording
A test variable is a defined name and value pair that stores and refers to information throughout a test and between tests. Having test variables allows for repeatability and reduces the burden of typing out the value each time it is needed.
In Sofy there are multiple ways you can create a test variable while recording a test case:
- Save Test Case Variable: Use this option and select a text component you want to save as a variable.
- Edit Text: Select this option, provide text, and create a new variable.
Saving a Test Case Variable During Recording
- Log in to your Sofy account.
- Select the Device Lab from the left navigation bar.
- Acquire and launch a device.
- Start recording your test case.
- Click the Save Test Case Variable option from the action bar to the right of the device.
- Select a text component from your app:
- The Save Test Case Variable modal will now open and in here, you can provide a name for your variable in the Variable Name field. While declaring a variable, you also tell Sofy if you want to treat this variable as a String, Integer or Float.
- You could also use regex to extract specific values from your variable value by enabling the Use Regex checkbox and providing a regex pattern for Sofy to check on:
- Once finished, you can click on Save option and continue recording your test case.
Editing Text and Creating a Variable During Recording
- Log in to your Sofy account.
- Select the Device Lab from the left navigation bar.
- Acquire and launch a device.
- Start recording your test case.
- Click into a text field in your app, then select Edit Text from the action bar to the right of the device.
- Select Create New Variable.
- Configure the following variable settings:
- Variable Type: Choose the variable type you want to create.
- Value: For test variables with a specific value, such as a name or email address.
- Variable Value: Enter the desired variable text.
- Pattern: Create a variable with specific patterns, such as numeric, alphabetic, alphanumeric, or date variables.
- Pattern: Choose between Numeric, Alphabetic, Alphanumeric, and Date.
- Length: Specify how many characters the pattern variable should contain. Only if you select Numeric, Alphabetic, or Alphanumeric.
- Select Date Format: Choose a date format. Only if you select the Date pattern.
- Secret: A variable used to store sensitive information like passwords or API keys.
- Variable Value: Enter the desired variable text. Click the eye icon at far right to show and hide the text.
- Value: For test variables with a specific value, such as a name or email address.
- Variable Name: Name of the variable.
- Description (optional): Describe the variable.
- Variable Type: Choose the variable type you want to create.
- Select Save Variable.
- To use the saved variable, click the dropdown under Select a variable and select the variable you just created.
- Select Set Text.
- Finish recording your test case.
Using Test Case Variables During and After Recording
You can use test case variables in the following areas:
- During test recording: You can use test case variables in the following action bar options located to the right of the device.
- Edit Text: Choose a variable under the Select a variable dropdown.
- Add API: Select Add new under Headers, Query Params, or Path Variables. You can select a variable from the Select Variable dropdown list.
- Add Assert: You can use saved variables for Text or Numeric asserts.
- Editing test case steps: If you want to add test case variables to a step after the test has been recorded, you can edit the desired test case step and use your variables in the following options:
- Add Assert: Select an element from the screen to the left and specify a saved variables for Text or Numeric asserts.
- Manual Overrides: Use a saved variable for the Content Desc, Resource ID, or Text settings.