Friday, June 11, 2010

File System Scripts

File System Scripts
File System Scripts
1) Create a Folder

Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\Jigargosai"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)

2) Delete a Folder

Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFolder("E:\Jigargosai")

3) Copying Folders

Set oFSO=createobject("Scripting.Filesystemobject")
oFSO.CopyFolder "E:\gcr", "C:\jvr", True

4) Checking weather the folder available or not, if not creating the folder

Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\Jigargosai"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
msgbox strDirectory & " already created "
else
Set objFolder = objFSO.CreateFolder(strDirectory)
end if

5) Returning a collection of Disk Drives

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = oFSO.Drives
For Each oDrive in colDrives
MsgBox "Drive letter: " & oDrive.DriveLetter
Next

6) Getting available space on a Disk Drive

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrive = oFSO.GetDrive("C:")
MsgBox "Available space: " & oDrive.AvailableSpace

File System Operations

File System Operations

File System:

By Jigar Gosai
Email: jigar.gosai@gmail.com


Its an operating system feature, it allows users to create, modify,
view and delete; drives,folders and files

VB Script is providing an object called scripting.filesystemobject
and some methods for performing file systems operations

Syntax for creating file system object:

Set variable=createobject ("scripting.filesystemobject")

Examples:

'Create a folder
Dim fso, strFolder
strFolder="D:\Documents and Settings\jigargosai\Desktop\smvs"
Set fso=createobject("scripting.filesystemobject")
fso.CreateFolder(strFolder)

'Create a folder
Dim fso, strFolder
strFolder="D:\Documents and Settings\jigargosai\Desktop\smvs"
Set fso=createobject("scripting.filesystemobject")
If fso.FolderExists(strFolder) Then
msgbox "Folder already exists"
else
fso.CreateFolder(strFolder)
End If

By Jigar Gosai
Email: jigar.gosai@gmail.com

VB Script Objects

VB Script Objects
VB Script Objects

Jigar Gosai Email: jigar.gosai@gmail.com

a) Dictionary Object


Dictionary Object that stores data key, item pairs.

A Dictionary object is the equivalent of a PERL associative array/Hash Variable. Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.



Creating a Dictionary Object:

Set objDictionary = CreateObject("Scripting.Dictionary")
Dictionary Objects Methods:

Add Method

Adds a key and item pair to a Dictionary object

Exists Method

Returns true if a specified key exists in the Dictionary object, false if it does not.

Items Method

Returns an array containing all the items in a Dictionary object.

Keys Method

Returns an array containing all existing keys in a Dictionary object.

Remove Method

Removes a key, item pair from a Dictionary object.

RemoveAll Method

The RemoveAll method removes all key, item pairs from a Dictionary object.

Example:

Dim cities
Set cities = CreateObject("Scripting.Dictionary")
cities.Add "h", "Hyderabad"
cities.Add "b", "Bangalore"
cities.Add "c", "Chennai"


Dictionary Objects Properties:
Count Property

Returns the number of items in a collection or Dictionary object. Read-only.

CompareMode Property
Sets and returns the comparison mode for comparing string keys in a Dictionary object.

Key Property

Sets a key in a Dictionary object.

Item Property
Sets or returns an item for a specified key in a Dictionary object. For collections, returns an item based on the specified key. Read/write.

Examples:

1) Add Elements to a Dictionary

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"   
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"


2) Delete All Elements from a Dictionary

Set objDictionary = CreateObject("Scripting.Dictionary")


objDictionary.Add "Printer 1", "Printing"   
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"
colKeys = objDictionary.Keys

Wscript.Echo "First run: "
For Each strKey in colKeys
    Wscript.Echo strKey
Next

objDictionary.RemoveAll
colKeys = objDictionary.Keys

Wscript.Echo VbCrLf & "Second run: "
For Each strKey in colKeys
    Wscript.Echo strKey
Next

3) Delete One Element from a Dictionary

Set objDictionary = CreateObject("Scripting.Dictionary")


objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"


colKeys = objDictionary.Keys


Wscript.Echo "First run: "
For Each strKey in colKeys
Wscript.Echo strKey
Next


objDictionary.Remove("Printer 2")
colKeys = objDictionary.Keys


Wscript.Echo VbCrLf & "Second run: "
For Each strKey in colKeys
Wscript.Echo strKey
Next

4) List the Number of Items in a Dictionary

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"   
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"
Wscript.Echo objDictionary.Count

5) Verify the Existence of a Dictionary Key

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"

If objDictionary.Exists("Printer 4") Then
Wscript.Echo "Printer 4 is in the Dictionary."
Else
Wscript.Echo "Printer 4 is not in the Dictionary."
End If

Jigar Gosai Email: jigar.gosai@gmail.com

VB Script Properties

VB Script Properties
VB Script Properties

VB Script Classes
Creating Classes


Classes aren't a new concept in scripting. JavaScript, JScript, and other scripting languages have supported classes or similar elements for years. However, VBScript 5.0 is the first version of VBScript to support classes.

To use classes in your VBScript code, you first need to obtain VBScript 5.0 by downloading the appropriate self-executable file from the Microsoft Developer Network (MSDN) Web site (http://msdn.microsoft.com/scripting) or by installing Microsoft Internet Explorer (IE) 5.0. Then you need to understand what a VBScript class is and learn how to declare, define, initialize, and instantiate a class.


VBScript Classes


VBScript 5.0 supports two types of objects: COM objects and Class objects (typically referred to as simply classes). VBScript COM objects have basic subtypes, such as an Integer or String. VBScript classes have an abstract subtype that encapsulates data and the functions to work with that data. You can think of a VBScript class as having a souped-up subtype that provides you with more computing power and flexibility. (Other differences exist between these two types of objects. For more information, see the Web-exclusive sidebar "How VBScript Classes and COM Objects Differ" on the Win32 Scripting Journal Web site at http://www.winntmag.com/ newsletter/scripting.


You can use classes to describe complex data structures. For example, if your application tracks customers and orders, you can define two classes for them, each with a unique set of internal data (typically called properties) and functions (typically called methods). You can then manage customers and orders as if they were native VBScript subtypes. More important, because you assign a class its properties and methods (i.e., its programming interface), you have an object-oriented tool to improve VBScript applications.


Declaring a Class


You use the Class statement to declare a class. This statement's syntax is:

Class name
' Properties and methods go here.
End Class
where name is the name you give that class. You declare the properties and methods for your class between the Class and End Class clauses.


For example, suppose you want to create the VBScript class FileList, which Listing 1 contains. This class manages those files in a folder that meet a filename specification that you provide. You create this class by first specifying the keyword Class followed by the class' name Class FileList. Next, you declare the class' properties and methods. FileList has two properties (FileSpec and FolderPath) and one method (Search).


Declaring the FileSpec Property


The FileSpec property holds the filename specification. For example, the filename specification might be C:\*.*. You want users to be able to freely read and write values to this property, so you declare FileSpec as an external, or public, variable with the Public statement


Public FileSpec

You can use a public variable in any script, not just the script in which you created the variable. However, if you use a public variable, you have no control over the value that users assign to the variable and no control over the value that the variable returns. Thus, you can't use public variables to hold values that you need to validate.


Declaring the FolderPath Property


The FolderPath property holds the full path to the folder containing the files. After a user sets a folder path, you need to validate that the folder exists, which means you can't use a public variable. Instead, you need to store the folder path in an internal, or private, variable and use two public property procedures to read and write to that variable. (Public property procedures are wrappers that hide the code that gets and sets the values of private variables.)


Prefixing a private variable with the m_ string is a common scripting convention. For example, the private variable for the FolderPath property is m_folderPath. To declare m_folderPath, you use the Private statement


Private m_folderPath


Procedures and variables that have the Private qualifier aren't visible outside the class. In addition, private variables apply only to the script in which you created them.


After you declare m_folderPath, you need to declare the two public property procedures that you'll use to read and write to that variable. The first procedure to declare is the Property Get procedure, which returns the values of properties. The second procedure is the Property Let procedure, which assigns values to properties.


To declare the Property Get procedure, you use the Property Get statement


Public Property Get FolderPath
FolderPath = m_folderPath
End Property
where FolderPath is the name of that procedure. By including the Public statement with the Property Get statement, you're making the value that the FolderPath procedure returns available for public reading. Thus, by assigning FolderPath to m_folderPath, you make the value of m_folderPath available for public reading.

Wednesday, June 9, 2010

Dynamic handling of object Repositories in QTP

Dynamic handling of object Repositories
Dynamic handling of object Repositories


Loading repositories during running, finding path of the repositories and removing repositories is called Dynamic Handling of Object Repositories.


Using this feature we can increase QTP performance. To do this, QTP is providing an object called “RepositoriesCollection”.

By Jigar Gosai
Email: jigar.gosai@gmail.com


Syntax for Loading a Repository:
RepositoriesCollection.Add “Path of the Repository File”


Syntax for finding Position of the Repository:
Variable=RepositoriesCollection.Find(“Path of the Repository”)


Syntax for Removing the Repository:
RepositoriesCollection.Remove(position)


Syntax for Removing All Repositories:
RepositoriesCollection.RemoveAll


Example:
RepPath="C:\Documents and Settings\Administrator\My Documents\Login.tsr"
RepositoriesCollection.Add (RepPath)
systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "sudhakar"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
pos=RepositoriesCollection.Find(RepPath)
RepositoriesCollection.Remove(pos)
RepositoriesCollection.RemoveAll
***********************************


By Jigar Gosai
Email: jigar.gosai@gmail.com


Cloud Testing
Cloud Testing

ISTQB Certification
ISTQB Sample Paper - 3
ISTQB Sample Paper - 2
ISTQB Sample Paper - 1

QC Certification
QTPCertification Sample Paper (HP0-M15) Dumps


QTP Certification
QTP Certification Sample Paper (HP0-M16) Dumps

QTP Interview Questions and Answers
QTP Interview Questions and Answers - 1
QTP Interview Questions and Answers - 2
QTP Interview Questions and Answers - 3
QTP Interview Questions and Answers - 4
QTP Interview Questions and
Answers - 5

QTP Interview Questions and Answers - 6

Monday, June 7, 2010

Automation Framework (QTP Framework)

Automation Framework (QTP Framework):
By Jigar Gosai
Email: jigar.gosai@gmail.com


Automation Framework
Automation Framework (QTP Framework):


Accessing one Software Objects from another Software is called Automation.
(AUT is one s/w and Testing Tool is another s/w.)

Automation Framework:
It is a set of guidelines, assumptions and process developed by experts in order to perform a task(s) in an effective, efficient and optimized way.

A systematic approach for automating software applications.


Why Automation Framework:
In one project test automation we use various files, we perform various tasks, in order to organize and manage them all, a systematic approach (Automation Framework) required.


files to be used:
a) Flat files (.txt),
b) Excel files (.xls)
c) Object repository files (.tsr)
d) XML files (.xml)
e) Library files (.vbs)
f) Test Scripts (.mts)
g) Test Batch Files (.mtb)
h) Recovery scenario files (.qrs) Etc…)


Tasks to be performed:
a) Analyzing the application
b) Selecting Areas/Test Cases for Automation
c) Planning (Effort estimation,Schedule,Work allocation and Automation Framework implementation)
d) Creating Generic and project specific functions.
e) Creating required Automation resources(Functions,Object repository Files,Environment variable files---etc)
f) Creating Tests(Using Object Repository or Descriptive Programming)
g) Enhancing Tests(Inserting Checkpoints,Output Values,Transaction points,Flow Control Statements,Synchronization,Parametrization---etc )
h) Debugging and running tests(Individual test execution,Test Batch execution --etc)
i) Defining and exporting test results
j) Analyzing results
k) Test reporting
l) Defect Reporting using companies defect management system.
m) Modifying tests
n) Performing re and regression testing ---etc

Types Of Automation Framework:
Automation Framework is not a qtp feature, it’s a 3rd party concept. And this is purely local concept.(framework may vary from one company to another)

By Jigar Gosai
Email: jigar.gosai@gmail.com


1. Record/Playback or Linear Framework (1st generation framework).
In this Framework we create tests using recording,low resources maintenance, Form batches and executing tests.
Drawbacks: Modifications and maintanance are difficult,less command on scripts,low performance ---etc

2. Modular Framework.
In this Framework,reusable components can be recognized,first we concentrate on creating reusable components, then creating tests using those components.

Advantages:

It reduces test Automation time

Performance is high than recording and playback

Drawbacks:
Less usage of keywords,no concentration on Data driven testing and low performance than latest Frameworks like Keyword Driven Framework.

3. Data Driven Framework

In this Framework,we concentrate more on Data Driven testing.We recognize positive and negative scenarios,then collecting test data and parameterizing.

Advantages:

We can check reliability of the system,positive and negative testing.

Drawbacks:
Less concentration on complex Functionality Testing and low keywords usage.

4. Keyword Driven framework


5. Hybrid Framework


In the above frameworks Keyword Driven framework is very famous in the industry.
It is a mixing of more than one approach.

In this approach,we mix Data driven and Modular approaches OR Data Driven and Keyword Driven approaches---etc

Advantages:

Scope is very high as we mix different approaches,Flexible for performing any tasks.

Drawbacks:

Organizing and managing resources are difficult,complex architecture,low in performance.

NOTE: Now a days Mix of Data driven and Keyword driven approaches is a famous Hybrid Framework in the industry.

Keyword Driven Framework

Keyword:


1. Any word used as the key to a code


2 A reserved word used to identify a specific command, function etc.


(in our test automation example keywords are :

By Jigar Gosai
Email: jigar.gosai@gmail.com


Keywords to be used in Test Automation:

a) Test Objects (EX: Browser,page,webEdit,WinButton---etc)
b) Functions (Built-In and User defined)
c) Methods (Ex:Set,Select,Activate,Navigate---etc)
d) Statements (EX:Dim,If,For---etc)
e) Operators (EX: +,/,*,and,or,not---etc)

Keyword Driven Approach:
In this approach we use keywords for preparing tests. First we create tests and make them as functions, through framework we execute them and generate results.


Key elements of Automation Framework:
1. Well defined folder structure
2. Initialization script
3. Driver script
4. input data spreadsheet
5. process guidelines document


Why folder structure?
In order to create, store, organize and manage files a well defined folder structure required. Folder structure is a mandatory element of any framework, but folder names may vary from one framework to another and company to another .


Folder Structure:
1. Object Repository
2. Environment
3. Library
a) Company
b) Project Specific
4. Test data
5. Test log
6. Recovery scenarios
7. Miscellaneous

And

1. Initialization script (.vbs file)
2. Driver script (QTP Script file)

By Jigar Gosai
Email: jigar.gosai@gmail.com


1) Object Repository: In this folder we store object repository files(.tsr), all team members can use this repositories.
2) Environment: In this folder we store environment variables files(.xml), all team members can use this variables.
3) Function Library:this folder contains two sub folders one is for storing common functions of our company, another folder for storing our project specific functions(.vbs).
4) Test Data: in this folder we store test data required for data driven testing, for that we use either .xls files or .txt files or .mdb files.
5) Test Log: In this folder we store test result(excel sheet).
6) Recovery scenarios: In this folder we store qtp recovery scenarios files(.qrs).
7) Miscellaneous: in this folder we store the files other than above files(ex-process guideline doc and messages among team members and instructions by team lead etc).

And

1) Initialization script (.vbs file):
It launches qtp tool and calls driver script, at end it closes qtp tool.
2) Driver script (QTP Script file):
It is only the qtp script, we can associate all resources to this script(ex)

By Jigar Gosai
Email: jigar.gosai@gmail.com


By Jigar Gosai
Email: jigar.gosai@gmail.com


Cloud Testing
Cloud Testing

ISTQB Certification
ISTQB Sample Paper - 3
ISTQB Sample Paper - 2
ISTQB Sample Paper - 1

QC Certification
QTPCertification Sample Paper (HP0-M15) Dumps


QTP Certification
QTP Certification Sample Paper (HP0-M16) Dumps

QTP Interview Questions and Answers - 1
QTP Interview Questions and Answers - 1
QTP Interview Questions and Answers - 2
QTP Interview Questions and Answers - 3
QTP Interview Questions and Answers - 4
QTP Interview Questions and
Answers - 5

QTP Interview Questions and Answers - 6

By Jigar Gosai
Email: jigar.gosai@gmail.com