Scope in CloudTest

Document created by Dave Murphy Employee on Jul 20, 2017
Version 1Show Document
  • View in full screen mode

The Scope in CloudTest is a way to define which objects can access a certain CloudTest object/element. There are three types of scope in CloudTest: Private, Public and Local.

 

If the scope of an object is set to Private, then only elements inside it can access it. When its scope is Local, then elements at the same level can access it. And finally when its scope is set to Public, any element can access it.

 

To change any CloudTest element’s scope, right-click on it and go to Scope, then just select the desired option as shown on Figure 1.

 

 

Figure 1. Changing the scope of a CloudTest element.

Figure 2. Local Scope Example.

 

Private Scope.

A CloudTest object’s scope is set to private by default. When its scope is private, only items within it can access it. An example of this would be a validation that executes a JavaScript to assess whether it was a pass or fail.

 

Local Scope.

You need to set the scope of a CloudTest element to Local when other element(s) at the same level will need to access it or any of its properties. The same level means that the elements are children of the same parent.

 

A common example is a JavaScript that is trying to access the HTML response of a request (commonly the HTML Document of a page), Figure 2. The JavaScript will access the HTML response to extract some necessary values used later in the test case (this is also known as correlation). If the scope is not changed to local, then the error in Figure 3 will appear. Basically: “Item is not accessible due to scope”.

 


Figure 3. Error when not setting the correct Scope.

 

Public Scope.

You need to set the scope of a CloudTest element to Public when other element(s) at different level(s) will need to access it or any of its properties. This would be the case when the element trying to access it is nested one or more levels up or down.

 

An example would be a JavaScript trying to access the HTML Document response, but the JavaScript is not at the same level. The Figure 4 shows this case, the JavaScript “Extract data” is at the level of page “Homepage” but not at the level of the HTML Document “soastastore.com (6)”. Since the JS first accesses the Homepage Page so that it can access the HTML Document, then the HTML Document's Scope must be set to Public and the Homepage Page’s Scope must be set to Local.

 


Figure 4. Public Scope Example.

Attachments

    Outcomes