Declare a Variable, Variable Declaration in automation testing with Example in QTP



Declare a Variable, Variable Declaration in automation testing with Example in QTP



How will you declare a variable in QTP ?
Variable can be declare using a Keyword DIM . With the help of SET keyword value also can be assign to variable.
Example.
Dim tempt ' It Will declare the variable named tempt
Set tempt = 30 ' It Will assign a value 30 to tempt


Variable Declaration:
.There are following 3 ways to declare the variable:
  1. Dim Statement
  2. Public Statement
  3. Private Statement


We can understand it with the help of following example:
Dim Nos_Passenger
We can declare multiple variables by just separating the each variable name with comma
i.e. Dim Right, Left, Top, Bottom


Implicit Declaration: Variable can be declare implicitly also, Simple you need to use it name in available scripts. It is not good style because There is high chance of misspell on multiple paces reason of unexpected result when our scripts will run.
Due to this Reason, The Explicit Option statement is available to mandatory explicit declaration for all type of variables. The Option Explicit statement should be the first statement in your script.

Note:
As you know that The Dim keyword is used to declare the variables at the script level for all procedure with in the script level. And at procedure level, Variables are available only with in the procedure.

Public Statement variable can be access and used for all type of procedures in all scripts.
Private Statement variable can be access and used only for private procedures in any single script. Where these are declared.

Declare a Variable
Declare a Variable






Advantages and Disadvantages of Automation Testing













Virtual Objects with Example in QTP
Cross Platform Testing


What is Object Spy in QTP Ordinal Identifiers Alone can Make an Object Unique



Test Automation Frameworks Types



No comments:

Post a Comment

Popular Posts