Setting and Using Message Scope

Document created by Chris Sommerstad Employee on Jul 21, 2017Last modified by Jijius Jabez on Aug 11, 2017
Version 2Show Document
  • View in full screen mode

SOASTA CloudTest provides the ability to set scope on objects in the repository that will define whether an item is private, public, or local.

By default, a message's scope is 'private' (as shown on the right) and its response cannot be accessed by another item in the composition, such as a script. Using private scope as a default permits CloudTest to throw away the response as soon as it's received in order to save memory.

  •  Private means the item’s information cannot be accessed from the outside
  •  Local means that an item’s information can be accessed only by other items within the same parent container

    For example, making a Message local means that the Message can only be accessed by other items within the same Clip
  •  Public means the item’s information can be accessed from anywhere.

Messages can have individual scope regardless of whether they are included in collections, such as the page shown on the right.

In cases where a message response needs to be accessed, its scope can be set to 'public' or 'local' (depending on its location) in order to make its response information available for access. For any parent item in the path, its scope must also be set for access.


For example, if a script needs the response info from a message in the same test clip, set the message to local. However, if a script that needs the response info is in a different test clip than the message, then the message must have scope “public” along with the test clip containing the message. Any other parent objects, such as pages or groups, that the script must go through must also have public or local scope, depending upon where the script is in relation to the message. In the screenshot on the right, a message, search.jsp, has been set to local scope. Since it's in a group, the group is also set to local. With these settings, search.jsp can be modified by scripts within the test clip.

To set a clip element's scope

  1. Scope can be set for a message or browser action (or any selected object) by clicking its Scope icon until it toggles to the desired scope (public, private, or local). The message on the right has been toggled to local scope.


Scope can also be set by selecting the message and then applying Public, Private, or Local from the Etc. drop-down menu.

For example, in the screenshot on the right, applying the Local command will change the scope of search.jsp to “local” (the parent group is already local).

Using a message with local scope

Once a message has 'local' scope, it can be accessed by any other clip element in the same test clip. Its values can be used in scripts and to set clip properties. A typical method is to place a script after the scoped message. Such a script will typically refer to the position of the scoped message, do something with the message response, and then clear the response from memory.


For example, in a script placed immediately after the scoped message, you would get the preceding message using this code:

The script doesn't have to be the next item in a test clip. For example, if the message is two prior, use



var msg = $context.currentItem.previousItem;

There are a variety of uses for a given message response (including, but not limited to, the following example scripts:


Clear the Response of a Message

When you change the scope of a message its response then it needs to be cleared via your script in order to maximize performance. Once the message response that was scoped 'local' or 'public' has been used, clear the response to ensure that large responses do not stay in memory (if they are no longer needed).

Use the clearResponse method to do so.

For example, the line (msg.clearResponse();) as shown on the right.


var msg = $context.currentItem.previousItem;