Code snippets in EveryStep Recorder allow you to reuse common sequences of actions—such as user interactions or validations—across multiple scripts. By creating and managing snippets, you can streamline the scripting process and maintain consistency throughout your monitoring and load testing configurations.

Creating a New Snippet

Creating a Snippet While Recording

A new snippet can be created in EveryStep Recorder in the Recording mode as part of a new EveryStep script.

A snippet must be used in at least one monitoring device in order to be saved to the system library. To ensure the snippet is saved to the library, make sure to save the device that contains the script referencing the original snippet.

To create a new snippet:

  1. In Everystep Recorder, start recording a new script.
  2. In Recording mode, click Snippet on the left side menu and select Begin.
  3. In the Begin Snippet window, provide a unique name you want to use for the snippet.
  4. Continue recording the actions that you want to include in the snippet.
  5. To stop recording the snippet, on the left side menu, select Snippet > End.
  6. To save the snippet to the EveryStep library, playback and save the script and the associated device. Once the device is saved, the custom snippet will be available for reuse in other scripts.

Image and RIA Validation are not supported within snippets.

Defining a Part of the Previously Recorded Script as a Snippet

To define a part of the script code as a snippet:

  1. In ES Recorder, in the Script Code section, right-click the line after which you want the snippet to begin, then select Snippet > Begin from the context menu.
  2. To define the end of the snippet, right-click the last line of the script segment you want to include in the snippet, then select Snippet > End.
  3. Save the script and the device to add the snippet to the Everystep library.

Adding an Existing Snippet to a Script

During Recording

To reuse an existing snippet while recording a script:

  1. In the recording mode, click Snippet on the left side menu and select Insert Existing.
  2. Select the snippet from the list of available snippets. You can preview the code in the snippet preview window before adding it.
  3. Allow the system to replay the script with the added snippet to validate the script. Once the script has been replayed, the snippet will be added to the script code.

In a Pre-recorded Script

To add a snippet to a pre-recorded script, in ES Recorder, right-click a line (step) after which you want to add the snippet in the Script Code section and from the editor context menu, select Snippet > Insert Existing.

Using Context Parameters in Snippets

When working with code snippets in the EveryStep Recorder, context parameters declared during recording are not automatically saved or reused when snippets are applied elsewhere. This means that any parameter value—such as a password—must be manually re-entered each time the snippet is used.

To avoid this, and to reuse consistent parameter values across multiple scripts securely, you should store those values in the Dotcom-Monitor Secure Vault by creating a Crypt (name-value collection of encrypted variables). Once stored, convert the original context parameters in your script into Crypt Variables, as explained in the Working with Crypt Variables in EveryStep Recorder .

Example

Let’s say you’ve recorded a login step that includes a context parameter for a password.

In this case, If you define lines 11–16 as a snippet, the system will not retain the password’s value when the snippet is saved. Instead, you will have to add the password parameter value each time you re-use the snippet.

To avoid this and pass the value of the password parameter with the snippet, first you need to configure a new Crypt in Secure Vault to use it as a centralized storage of the password value.

Then, in EveryStep Recorder, convert the password parameter to Crypt Variable by saving it to the Crypt created on the previous step.

 

Editing a Snippet

A custom snippet is available for editing only as a part of the script in the Everystep Recorder window.

To edit a snippet:

  1. Open the script containing the snippet in EveryStep Recorder.
  2. Make changes to the snippet code using the same methods described in Editing a Script in EveryStep Scripting Tool.

When saving changes to a snippet, the system validates all associated scripts. If any script fails validation, the changes cannot be saved.

Applying Changes to a Specific Device Only

To apply snippet changes to a single device without affecting the other scripts using the original snippet:

  1. In the Edit Code section, click the BeginSnippet method for the snippet you want to edit.
  2. Provide a new, unique name for the snippet in the snippet settings.
  3. Close the snippet settings panel.
  4. Save the device to create a new instance of the snippet in the snippet library.

Deleting a Snippet from the EveryStep Library

Remove the snippet from all devices that utilize it.

If a snippet is associated with only one device, it will be automatically deleted upon the device’s removal.

 

For more detailed guidance on using EveryStep Recorder and managing code snippets, please refer to the EveryStep Scripting Tool documentation.