Qtp namespace overview by terry horwath

Solo disponible en BuenasTareas
  • Páginas : 5 (1135 palabras )
  • Descarga(s) : 0
  • Publicado : 30 de mayo de 2011
Leer documento completo
Vista previa del texto
Note: in this section we will use the term, variable, to mean a simple variant, a constant, a class, an object, or a function name.

The notion of namespaces are left up to each runtime interpreter. For example Windows Scripting Host (WSH) provides three namespaces:

Global namespace: any variable defined outside a class or a function.
Class namespace: any variable defined within avbScript Class definition
Function namespace: any variable defined within a function
QTP provides the following namespaces:

Global namespace: any variable defined in a file included on the Test Settings… Resource tab—more details in the next section.
Action namespace: any variable defined within a test Action, or in a file included within an Action using the ExecuteFile statement—more details inthe next section).
Class namespace: any variable defined within a vbScript Class definition
Function namespace: any variable defined within a function
Class and function namespace scoping and visibility work just as they do in most other language/run-time environment, and will be not be mentioned further. But much confusion arises from QTP’s undocumented behavior with variables placed in theAction versus the Global namespaces:

Variables defined and initialized within an Action persist for one iteration of that Action. If the action is called multiple times in a given test run—which is often the case when an Action is data table driven—then a fresh set of variables are used on each Action iteration.
An Action’s variables are not visible/accessible to code in the Global namespace.But of course Global namespace variables are accessible to all test Actions. Visibility/access is from the most private namespace to the least private:
Global namespace

Action namespace

Class/Object namespace (Visibility/Accessibility)

Function namespace



Action A’s variables are not visible/accessible to code in Action B. But Action A canoptionally call Action B and pass it one or more parameters (and if they are passed by reference, then Action B can modify Action A variables).




1.1 QTP File Inclusion Mechanisms

vbScript provides no support for file inclusion. Rather it leaves implementation of this capability up to each runtime interpreter. For example Windows Scripting Host (WSH) provides no file inclusion support,while QTP provides two different mechanisms:

Associating a library file on the Test Settings Resource tab. This can only be accomplished using the QTP IDE, which saves this information in each test’s test.tsp binary proprietary file. You can inspect an existing test’s associated libraries using this IDE as well:
Files included on the Resource tab are placed in the test’s Global namespace atruntime, and are therefore shared and accessible by all Actions included in the test.

Including a library in a test Action, using the ExecuteFile(“libname”) QTP statement. Libraries included in this manner are placed in the including Action’s namespace, and therefore may only be used by the including Action’s code.
It is also possible to use one or more ExecuteFile(“libname”) statements within alibrary included via the Test Settings Resource tab as well. In this scenario all library files are placed in the test’s Global namespace.
Note: symbolic debugging is effected by the selected inclusion method:

While all of the above techniques place code in the desired namespace, only files included using the Test Settings Resource tab technique can be symbolically debugged. So in case #3above, if a.vbs is explicitly included on the Test Settings Resource tab, and then it includes b.vbs and c.vbs using ExecuteFile() statements, you will only be able to symbolically debug problems that occur in a.vbs.
So, any load time or run-time errors encountered in any file included using the ExecuteFile() function result in a nonsense exception being thrown by QTP—most often pointing to the...
tracking img