Adding an Assign step
You can use the Assign step to assign values from datasets to test variables or store values extracted from UI elements in variables during a test run.
Before you begin
- Ensured that you are assigned a Team Space Owner, Project Owner, or Member with a Tester role to create or edit a test resource.
- Read and understood the information in Edit branch overview and Create or select an Edit branch.
- Ensured that your project contains a Web UI test or suite.
- Ensured that the required variables have been created and are included in your Web UI test or suite.
- Ensured that your project contains a dataset.
About this task
You can use the Assign step to assign values to variables during a test run. You can assign values from datasets to support data-driven testing or extract values from UI elements and store them in variables. The assigned values can then be used in subsequent test steps to perform flexible data-driven testing across multiple scenarios
Procedure
-
Click the
button displayed on the Test
Editor page.
The Edit button appears only when no active edit branch is selected.
Alternatively, right-click the test in the test navigator panel and select Edit.
The Edit branch dialog is displayed.If the Edit branch dialog is not displayed, then go to step 3.
- Select an existing branch or create a new branch.
-
Drag the Assign statement from the pane and drop it under a test step as required.
The Assign step is inserted.Note:
You can also use the Assign step within a while or do-while step, so that the Assign step retrieves the values from a dataset to process each row of the dataset iteratively and assign the retrieved values to the test variables.
-
Click the Assign step.
The step details pane opens with the Details tab which was the default selection.
-
Select the required mode from the Mode list:
- UI
- General
Note:The default mode depends on where the If step is added. When the If step is added within a With step, it opens in UI mode. When it is added outside a With step, it opens in General mode.A confirmation dialog is displayed, indicating that switching modes clears the current step configuration.
-
Click Yes.
Note:
- The default mode depends on where the Assign step is added. When the Assign step is added within a With step, it opens in UI mode. When it is added outside a With step, it opens in General mode.
- You can switch between the available modes by selecting a different option from the Mode list.
- If you switch modes after configuring the step, select the required mode and then click Yes in the confirmation dialog. The existing configuration is cleared and the step opens in the selected mode.
-
You can perform the actions that are listed in the following table to configure
assign during a test run:
Mode Action General Perform the following steps:- Select an existing dataset in the Dataset field.
- Click Add to add a variable and assign the value from dataset.
- Select an existing variable from the
Select a variable to assign
drop down.Note:The variable is displayed in the Variables section.You can also select Create variable from the list to create a new variable and assign the value from the dataset.
- Select the column in the dataset from which you want to assign the values during test run.
- Click the Close icon
to close the run details
pane.
UI Perform the following steps:- Hover over a UI element in the
Smartshot view,
right-click, and then select Use this
element as a step
target.
Alternatively, you can drag and drop a UI element from the Smartshot view to the Object identified by section.
The UI Object type is identified.
- Enter a property name such as Content, Id, or
XPath of the object that must be used for variable
assignment in UI
Property.
If you entered the property name correctly, the value of the property is displayed under Extracted Value.
- Select an existing variable, or Select Add new variable, enter a name for the variable, and then click Add.
-
Click the Save icon
to save the
modifications.