Creating a Variable During Test Case Recording

Updated by Aishwarya Rai

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

  1. Log in to your Sofy account.
  2. Select the Device Lab from the left navigation bar.
    Sofy home page with a callout over the Device Lab left navigation option.
  3. Acquire and launch a device.
  4. Start recording your test case.
  5. Click the Save Test Case Variable option from the action bar to the right of the device.
  6. Select a text component from your app:

  1. 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:
  2. 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:
  3. Once finished, you can click on Save option and continue recording your test case.

Editing Text and Creating a Variable During Recording

  1. Log in to your Sofy account.
  2. Select the Device Lab from the left navigation bar.
    Sofy home page with a callout over the Device Lab left navigation option.
  3. Acquire and launch a device.
  4. Start recording your test case.
  5. Click into a text field in your app, then select Edit Text from the action bar to the right of the device.
    Device Lab recording with a callout over the Edit option in the action bar.
  6. Select Create New Variable.
    Set Text modal window with a callout over the Create New Variable button.
  7. Configure the following variable settings:
    1. Variable Type: Choose the variable type you want to create.
      1. Value: For test variables with a specific value, such as a name or email address.
        1. Variable Value: Enter the desired variable text.
      2. Pattern: Create a variable with specific patterns, such as numeric, alphabetic, alphanumeric, or date variables.
        1. Pattern: Choose between Numeric, Alphabetic, Alphanumeric, and Date.
        2. Length: Specify how many characters the pattern variable should contain. Only if you select Numeric, Alphabetic, or Alphanumeric.
        3. Select Date Format: Choose a date format. Only if you select the Date pattern.
      3. Secret: A variable used to store sensitive information like passwords or API keys.
        1. Variable Value: Enter the desired variable text. Click the eye icon at far right to show and hide the text.
    2. Variable Name: Name of the variable.
    3. Description (optional): Describe the variable.
  8. Select Save Variable.
  9. To use the saved variable, click the dropdown under Select a variable and select the variable you just created.
    Set Text modal window with a callout over the Select a Variable option.
  10. Select Set Text.
  11. 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.

 


How did we do?