Reflect Docs

Segments & Composition

Segments are named sequences of test steps that can be executed within any Test. Changes to a Segment are reflected in any Test that references it.


Often the individual test cases throughout a regression suite will share (or duplicate) shorter sequences of actions. For example, a collection of tests related to a webapp’s Settings page will most likely share an initial sequence of logging in to the webapp, and then at some point, navigating to the Settings page. If each test case duplicates those sequences, then a problem arises when the sequences change and each test needs to be updated individually. Reflect uses segments to solve this problem.

A segment is a named sequence of test steps, which can be referenced and executed by any test. If the segment’s steps are updated or changed, then those changes propagate to the dependent tests on their next test run. A segment can be referenced anywhere within a test, which allows you to compose arbitrary test cases from reusable building blocks.

Note: Only tests can reference segments. Segments cannot reference other segments so there is no ability to create nested segments.

Create a Segment

To create a segment, simply select the contiguous test steps from any test definition and click “Create a Segment” from the bulk action bar that appears at the bottom of the page. You must select two or more test steps to create a segment, but you can edit the segment after it is created (see below).

Enter a name for the new segment into the modal and click “Add Segment”. Finally, save and run the original test to save the reference to the new segment.

View a Segment

You can view a segment from any test definition that references it, or from the segment’s definition page itself. To load a segment’s definition page, click the “View” link next to the segment from the main Segments list page.

Edit a Segment

Editing a segment is just like editing regular test steps. First, go to a test that references the segment that you want to edit. Next, click on the test step inside of the segment on the left sidebar that you want to edit. The test step detail pane will be displayed, and from there you can make changes such as configuring element selection or updating the Expected Text. You can make changes to as many test steps inside of the segment as you want. When you are finished creating changes, there will be a message at the bottom of the left sidebar indicating how many test steps were modified. The left sidebar also displays a “Save” button. When you click the “Save” button, you are updating both the segment’s definition, as well as any test that references the segment to use the segment’s updated definition. Thus, any future execution of a test that references the segment will use the updated test steps.

Unassign a Segment

Unassigning a segment removes the reference to a segment from a test but leaves all of the segment’s literal test steps in the original test. After removing the segment reference, you can (bulk) delete the segment’s test steps if desired. The unassign operation is distinct from deleting a segment, and is useful when creating newer segments from a subset of an existing segment’s steps. Unassigning a segment does not change the segment’s definition or steps.

To unassign a segment, view the definition of a test that references the segment. Click on the right-facing “›” arrow to the right of the segment name in the left sidebar to open the segment detail panel.

Finally, click “Unassign Segment” in the detail panel, and then save the changes in the parent test.

Delete a Segment

To delete a segment, go to the segment’s definition page and click the “Delete” button at the top of the page. You cannot delete a segment that is referenced by any tests. You must unassign the segment reference from within each test before deleting the segment.

Starting Segments

To record a new test and use segments as the initial test steps, there must be at least one segment in your Reflect account. Click “Create Test” to open the test recording modal. Enter a name, a starting URL and a device profile for your new test.

Next, select as many segments as you’d like from the Segments dropdown. Only segments that match the test’s device profile can be selected. Furthermore, keep in mind that the segments will execute in succession within the same browser tab. So, each segment’s first action should operate on the same URL as the prior segment’s last action. Otherwise, your test may fail due to an element not being found on mismatched URLs. This requirement includes entering the starting URL for the test. The first segment you select must operate on the same URL as the test’s starting URL.

Finally, click “Begin Recording” to initiate the test. Reflect will initialize a new browser and execute the test steps in sequence from all of the segments. Then, it will enable the normal recording experience where you can record new test steps.

Get started with Reflect today

Create your first test in 2 minutes, no installation or setup required. Accelerate your testing efforts with fast and maintainable test suites without writing a line of code.

Copyright © Reflect Software Inc. All Rights Reserved.