Tuesday 31 December 2013

what is Validation

Validation checks that the product design satisfies or fits the intended use (high-level checking), i.e., the software meets the user requirements. This is done through dynamic testing and other forms of review.
Validation: Are we building the right product? (This is dynamic process for checking and testing the real product. Validation always involves with executing the code)
Validation: The process of evaluating software during or at the end of the development process to determine whether it satisfies specified requirements. [IEEE-STD-610]
It is a High level activity.
Performed after a work product is produced against established criteria ensuring that the product integrates correctly into the environment.
Determination of correctness of the final software product by a development project with respect to the user needs and requirements.
Validation ensures that the software operates as planned in the requirements phase by executing it. Running predefined test cases and measuring the output with expected results.

Monday 30 December 2013

Procedures in VB Script


Procedures:

ü  is a series of statements, enclosed by the Sub and End Sub statements
ü  can perform actions, but does not return a value
ü  can take arguments
ü  without arguments, it must include an empty set of parentheses ()

Sub mysub()
  Print "my Sub Procedude"
End Sub

or

Sub mysub(argument1,argument2)
  Print "my Sub Procedure"
End Sub


To call a Sub, you will use Call statement by enclosing arguments (if any) in parentheses.
The Call statement is not necessary to call a Sub, but if you want to use Call statement (Recommended), you must enclose arguments (if any) in parentheses.

Call mysub(argument1,argument2)
You can call a Sub without using Call statement as well, but not recommended.

mysub argument1,argument2

Wednesday 25 December 2013

What is Functions


What isFunctions? Explain Features of Functions,Types of Functions and Calling aFunction



·         is a series of statements, enclosed by the Function and End Function statements
·         can perform operations and can return a value
·         can take arguments that are passed to it by a calling procedure
·         without arguments, must include an empty set of parentheses ()
·         returns a value by assigning a value to function name itself

Function myfunction1()
  Print "my fuction1"
End Function

or

Function myfunction2(a,b)
myfunction2=a+b  'assign value to function name
End Function


How to call Function Procedures:

Call myfunction1() 'calling 1st function, without any return value

x=myfunction2(argument1,argument2)  'calling 2nd function, with a return value

Here you call a Function called "myfunction2", the Function returns a value that will be stored in the variable "x"
Functions are used for Placing or Storing the Code which is to be Repeated Several Times. For Example, if we need Same Code, then we must have to Write that Code Again and Again So that for Removing this Task, we uses functions.
The Functions are Some Storage Area which Contains set of Statements and the Function Executes all the Contained Statements when a Special Call is made to them. Once a Code is stored in the Function, then we can Store that Function any time and Any Time we can call that Functions.
 Functions are used for performing the repetitive task or we can say the functions are those which provides us the better efficiency of a program it provides us the facility to make a functions which contains a set of instructions of the repetitive types or we need them in a program at various places Thus a functions provides us the ability to make a function which contains a code and then use them when a functions can call then it executes the statements those are contained in it.

Functions Provides us Following Features
1) Reusability of Code : Means Once a Code has Developed then we can use that Code any Time.
2) Remove Redundancy: Means a user doesn’t need to Write Code Again and Again.
3) Decrease Complexity: Means a Large program will be Stored in the Two or More Functions. So that this will makes easy for a user to understand that Code.

          There are Two Types of Function
                   1) Built in Functions
                   2) User Defined functions

The Functions those are developed by the user for their Programs are known as User Defined Programs. When a user wants to make his Own Function, then he must have to follow the Following Operations.
          1) Function Declaration or Prototyping
          2) Function Defining
          3) Calling a Function
1) Function Declaration or Prototyping:For using a Function a user must have to declare a Function. The Function declaration contains the Name of Function, Return type of the Function and also the Number of Arguments that a User will takes for performing the Operation.

                             The Function Prototyping Contains
1) Return Type of a function: The Return Function determines whether a Function will return any value to the Function. If a Function is declared with the void Keyword or if a Function Contains a void then that’s means a Function Never Returns a value. Means a Function will Executes his statements one by one. And if a Function Contain any other data type means if a Function Contains int or Float then the Function must return a value to the user.
2) Name of Function : The Name of Function must be valid and the name of function must be Start from any Alphabet and the Name of Function doesn’t Contains any Spaces and the Doesn’t Contains any Special Character For Example Space , * sign etc.
3) Argument List: A Function may have zero or More Arguments. So that if we want to call a Function. Then we must have to Supply Some Arguments or we must have to pass some values those are also called as the Argument List. So that The Argument List is the total Number of Arguments or the Parameters those a Function Will takes. So that We must have Supply Some Arguments to the Functions,. The Arguments those are used by the Function Calling are known as the Actual Arguments and the Arguments those are used in the Function declaration are Known as the Formal Arguments, When we call any Function then the Actual Arguments will Match the Formal Arguments and if a proper Match is Found, then this will Executes the Statements of the Function otherwise this will gives you an error Message.



There are Two Ways for Calling a Function
1) Call by Value:-when we call a Function and if a function can accept the Arguments from the Called Function, Then we must have to Supply some Arguments to the Function. So that the Arguments those are passed to that function just contains the values from the variables but not an Actual Address of the variable.
So that generally when we call a Function then we will just pass the variables or the Arguments and we doesn’t Pass the Address of Variables , So that the function will never effects on the Values or on the variables. So Call by value is just the Concept in which you must have to Remember that the values those are Passed to the Functions will never effect the Actual Values those are Stored into the variables.
2) Call By Reference :-When a function is called by the reference then the values those are passed in the calling functions are affected when they are passed by Reference Means they change their value when they passed by the References. In the Call by Reference we pass the Address of the variables whose Arguments are also Send. So that when we use the Reference then, we pass the Address the Variables.
When we pass the Address of variables to the Arguments then a Function may effect on the Variables. Means When a Function will Change the Values then the values of Variables gets Automatically Changed. And When a Function performs Some Operation on the Passed values, then this will also effect on the Actual Values.

Dynamic arrays

An array can hold more than one value. An array lets you address many data values through the same variable. Think of an array as a list (e.g., a list of usernames). You reference each item in this list with a common name and index number. The common name is the name of the array variable. The common name typically includes the prefix arr to denote that the variable contains data of the subtype Array. The index number is an integer subscript that denotes an item's relative location in the list. The indexes always increment sequentially, starting from 0. For example, if an array has three items, the indexes are 0, 1, and 2. The 0 index represents the first position, the 1 index represents the second position, and the 2 index represents the third position in the array.
There are two types of arrays:

Static array has to be declared with the number of elements that the array can hold (i.e. arr(5)).  If we don’t know the number of elements to be stored in the array, then the dynamic array can be used.
Syntax:
Dim arr()
ReDim keyword should be then used to declare the number of elements that the array can hold.
Syntax:
Dim arr()
ReDim arr(3)
Example:
Dim arr()
ReDim arr(3)
    arr(0)=10
    arr(1)=15
    arr(2)=20
msg=""
For i=0 to 3
    msg=msg&"Arr("&i&") : "&arr(i)&vbnewline
Next

msgbox msg

ReDim arr(4)
arr(4)=20
msg=""
For i=0 to 4
    msg=msg&"Arr("&i&") : "&arr(i)&vbnewline
Next
msgbox msg
In the above example, array is initially sized with five elements.  Array elements with indices 0 to 5 are initialized and displayed using for loop.  The array is resized with ReDim keyword and then the added array element is initialized with the statement “arr(4)=20”.

Output before resizing the array:
dynamicarray1
Output after resizing the array:
dynamicarray2
We will use the Preserve keyword with the ReDim in the above example.
Dim arr()
ReDim arr(5)
    arr(0)=10
    arr(1)=15
    arr(2)=20
    arr(3)=25
msg=""
For i=0 to 4
    msg=msg&"Arr("&i&") : "&arr(i)&vbnewline
Next

msgbox msg

ReDim Preserve arr(6)
arr(4)=20
msg=""
For i=0 to 4
    msg=msg&"Arr("&i&") : "&arr(i)&vbnewline
Next
msgbox msg
Output shows the array element values starting from Arr(0) to Arr(6).  Preserve keyword preserves the values of the array elements before ReDim statement.  Hence, if we resize the array with ReDim and add new elements does not erase the earlier values of the array.

Follow the steps below to use the dynamic arrays:

Declare the array with no size – Dim array_name()
Re-declare the size of the array with ReDim & Preserve – ReDim Preserve array_name(number of elements)

Tuesday 24 December 2013

Record and Playback in QTP



Initial development of automated tests with QTP is usually done by record-and-playback. A user’s actions are captured via Microsoft’s Component Object Model (COM). These are recorded into Actions, a kind of subroutine, as VBScript commands. All manipulated objects that QTP recognizes are also added to the object repository. Once recorded, the scripts are editable in either Keyword View or Expert View.
After clicking on the playback button all these actions will be played back. During playback, QTP attempts to identify and perform operations on the same objects, again using COM.
Recording Modes: There are three recording modes in QTP
Normal
Analog
Low Level
NormalRecording Mode: It records the actions performed by the user on the application objects like Edit boxes, List boxes and Links. QTP records each action as one step in the QTP script. Step is nothing but one line in the code.


·         Launch QTP
·         Create a new test by selecting  File>New>Test
·         Click Record button or select Automation>Record or press the Record command shortcut key F3.
·         The Record  and Run settings dialog opens as shown below, Enter Application URL in the box as shown in our case .When  you are done with recording click the Stop button or select Automation>Stop or press F4.
·         Save Your Test.
·         Run the test by clicking Run.


AnalogRecording Mode: This mode enables you to record the exact mouse and keyboard operations you perform in relation to either the screen or the application window. This mode is useful when you want to record mouse movements, for example recording a signature or drawing performed by dragging the mouse. To record in analog mode , first start normal recording then select Automation>Analog Recording. The Analog recording dialog box opens up as shown below.
Record relative to the screen: QTP records any mouse movement or keyboard input relative to the top
  left coordinates of your screen(i.e. desktop).

  Record relative to the following window: QTP records any mouse movement or keyboard input
   relative to the coordinates of the specified window.
Low Level Recording:
 Low level recording mode is used only when exact coordinate of the operation is essential. To record a test using low level recording mode, start the normal recording session then select Automation>Low Level Recording to start recording in low level
(code created in low level recording)
Window("Oracle VM VirtualBox Manager").Window("Create New Virtual Machine").WinObject("Cancel").Click 40,17

This code states that Cancel button was clicked at  coordinate 40,17. This coordinate is measured by taking top left corner of the object( Here it is the Cancel button) as reference (0,0).

Use Analog recording mode only when normal recording mode does not accurately record your operations.
Use analog recording for the applications in which the actual movement of the mouse is what you want to record, like drawings, signatures etc.
Use low level recording when you need to record the exact location of the operation on your application screen.
Running Tests:
QTP always run from the first step, unless you specify otherwise.To run a test , open it and select Automation>Run or press F5.The Run dialog box opens, in the dialog box specify the result location. Temporary run result folder saves run results in a temporary folder.This option overwrites any results previously saved in this folder. Click OK to start the Run session.
Test Result Window: When a run session ends, you can view run session results in the Test Results window. The run result tree is located in the left pane in the Test Result window
Recordand Run Settings Dialog: This Dialog box is used to instruct QTP , which application to open when you begin to record or run your test.
WindowsApplication Tab: As shown in figure below.There are two radio buttons, if we select first one QTP records and run test on any application and if we select a second one, we can specify the applications on which QTP should record or run test.
  Web Tab: Web Tab as shown below also have two radio buttons, if select the first one,QTP records and run test on application opened on any browser and if we select the second one, QTP records and runs tests by opening application in a new browser of the specified type.

Monday 23 December 2013

Lifetime of Variables


Lifetimeof Variables
Lifetime of a Variable : It is the period for which they retain their value. Variables declared as Public exist for the lifetime of the application. Local variables, declared within procedures with the Dim or Private statement, live as long as the procedure.
You can force a local variable to preserve its value between procedure calls with the Static keyword. The advantage of using static variables is that they help you minimize the number of total variables in the application.
In addition to scope, variables also have a lifetime, which is the time during which a variable retains its value. The values in module-level and public variables are preserved as long as the database is open (unless you reinitialize your code).
You can force a local variable to preserve its value between procedure calls with the Static keyword. The advantage of using static variables is that they help you minimize the number of total variables in the application.

Variables declared in a Form outside any procedure take effect when the Form is loaded and cease to exist when the Form is unloaded. If the Form is loaded again, its variables are initialized, as if it’s being loaded for the first time
This is true for form and report module-level variables even if you close the form or report. However, local variables declared with the Dim keyword exist only while the procedure in which they are declared is running. Usually, when a procedure has finished, the values of its local variables are discarded and the memory used by the local variables is reclaimed. The next time the procedure is run, all of its local variables are reinitialized. However, you can make Visual Basic preserve the value of a local variable by making the variable static.

To make a local variable in a procedure static, use the Static keyword to declare the variable exactly as you would using the Dim statement.

Static intX As Integer

For example, the following function calculates a running total by adding a new value to the total of previous values stored in the static variable dblAccumulate.

Function RunningTotal(ByVal dblNum As Double) As Double
   Static dblAccumulate As Double
   dblAccumulate = dblAccumulate + dblNum
   RunningTotal = dblAccumulate
End Function

If you declare dblAccumulate with the Dim keyword instead of the Static keyword, the previous accumulated values aren't preserved across calls to the function, and the function simply returns the value with which it was called.

You can produce the same result by declaring dblAccumulate in the Declarations section of the module, making it a module-level variable. However, after you change the scope of a variable in this way, the procedure no longer has exclusive access to that variable. If other procedures access the value of the variable and change it, the running totals would be unreliable.

To make all local variables in a procedure static, place the Static keyword at the beginning of a procedure declaration, as shown in the following example:

Static Function RunningTotal (ByVal dblNum As Double) As Double
This makes all the local variables in the procedure static, regardless of whether they are declared with the Static or Dim keywords, or declared implicitly. You can place the Static keyword in front of any Function or Sub procedure heading, including event procedures and those that are also declared as Private.