Wednesday, 27 May 2015

QTP - 15 - Parameterization in QTP?

Parametrization is the process of running the same script on same application using different data.It is the process of making use of different values in place of recorded\scripted values which is replaced by variable which contains different values that can be used during the execution of the scripts.

QTP enable us with different type of Parameterization,they are:

1) Using Loop statement.
2) Dynamically test data submission
3) Using data table.
4) Fetching data from external files like excel or text files.
5) Fetching data from databases.
6) By taking test data front end(GUI)
7) Test/Action parameters
8) Environment variable parameters
9) Random number parameters
10)Using Library objects

QTP - 14 - Phases involved in testing an application With QTP?

The automation process consists of the following main phases:

Automated Testing Process

Analyzing Application: before preparing test cases need to analyze the application to find out the testing needs.We can also name this step as feasibility analysis.We check that the given application can be automated or not. few applications has few limitations due to which it can't be automated.

Appropriate Tool Selection - The Next most important step is the selection of tools. It depends on the technology in which the application is built, its features and usage. Sometimes the project budget is also an importatnt thing while choosing tool.

Evaluate the suitable framework - Upon selecting the tool the next activity is to select a suitable framework. There are various kinds of frameworks and each framework has its own significance. We will deal with frameworks in detail later this chapter.

Preparing Testing Infrastructure: based on testing needs create those resources, resources like, shared repository, function library etc.

Building Test Cases: create test script containing action to be performed while testing. Add object repository with the test function libraries.

Enhancing Test: by making use of checkpoints, broadening the scope of test, add logic and condition to test for checking purpose.

Debugging, Running and analyzing Test: debug the test so that it works without interruption. Run these test and analyze the test result generated by QTP

Report Defects: lock bug into the bug report and send it to the development team.

QTP - 13- Scenario specific - To generate unique random numbers in QTP?

There are basically many methods to generate random numbers in QTP. Major among them are using loops or creating two loops and concat it. But these methods has limitations of generating numbers in a particular range and if we want unique number on daily basis this methods fails. We need to alter the scripts on daily basis. We can also use Randomize() function given by QTP but again there is no surity that all the numbers generated by them are unique.
So here we can do the following things :

1) Use Randomize function and concanete it with timestamp , it will be unique

Randomize
iTmp = Int((sMaxVal * Rnd) + 1)

2) Use date time and second methods and concanete it. It will always generate a random number

Dim sDate : sDate = Day(Now)
Dim sMonth : sMonth = Month(Now)
Dim sYear : sYear = Year(Now)
Dim sHour : sHour = Hour(Now)
Dim sMinute : sMinute = Minute(Now)
Dim sSecond : sSecond = Second(Now)

Int(sDate & sMonth & sYear & sHour & sMinute & sSecond)

Wednesday, 13 May 2015

QTP - 12 - Keyword and expert View !

The Keyword view is a table view of the QTP Active screen whereeeach step is a seperate row in the table and each column represents different part of the steps. There are basically 4 columns in Keyword view :

- Item Column contains the item on which you want to perform the step. This column uses icons displays the hierarchy of the GUI object on which operation is performed

- Operation Column contains the operation to be performed on the item. We can add/remove any step from here.

- Value Column contains the argument values for the selected operation,it is used for parameterization purpose.

- QTP automatically documents each step for easy understanding in the Documentation Column
These 4 columns are default but you can also use assignment & comment columns in Keyword View


In The expert view , we can view an editable screen in QTP where we can write our VB codes. For each row in Keyword view a step is generated in expert view.

QTP - 11 - Types of recording modes in the QTP!

The QTP Supports three types of recording:

-> Normal (Default recording): In this recording mode QTP identify the object irrespective of their location on the screen. It is done by recording object based on application window.It records the properties of each object and compare it while execution.Also known as context sensitive recording , this mode records the object and operation performed on them.

-> Analog Recording: In analog recording mode, Quick Test Professional  records and tracks every movement of the mouse as you drag the mouse around a screen or window.It is used when exact mouse movement and action performed by mouse is important. Used in testing the paint application and signature made with the help of mouse.It depends on the  mouse movement.

-> Low Level Recording: it helps in identifying those objects which is not recognized by the QTP. It is used when the location of object is changing inside the screen.It uses co-ordinates to record the objects.It is used when the exact coordinates of the object are important for your tests.

->Insight Recording: There are instances that the developer does not assigns the object property or the property assigned are not enough to identify an object uniquely. In such instances QTP/UFT uses insight recording mode. In this mode UFT sends the screenshot of the objects to the scripts. While executing the UFT identifies the object using this.

Sunday, 10 May 2015

QTP - 10 - Checkpoints -All about it !!

Checkpoints are internal validations given by QTP, which is used to capture a property during record and playback. Although the checkpoints are rarely used in real time Testing but we should be aware of it :

1) Standard Checkpoint - Verifies the property values of an object in application under test and supported by all add-in environments.

2) Bitmap Checkpoint - Verifies an area of your application as a bitmap.Bitmap checkpoint enables user to compare two bitmaps. User can compare complete bitmaps as well as part of the bitmaps.

3) File Content Checkpoint - Verifies the text in a dynamically generated or accessed file such as .txt,.pdf

4) Table Checkpoint - Verifies the information within a table. Not all environments are supported.

5) Text Checkpoint Verify if the text that is displayed within a defined area in a Windows-based application, according to specified criteria.

6) Text Area Checkpoint - Verifies if the text string is displayed within a defined area in a Windows-based application, according to specified criteria.

7) Accessibility Checkpoint - Verifies the page and reports the areas of the Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines.Accessibility enables user to check whether the webpage in our web application is developed according to W3C (World Wide Web consortium) Rules and Regulations or not.It is a configurable checkpoint, according to our requirements, we can customize.

8) Page Checkpoint - Verifies the characteristics of a Web page. It can also check for broken links.

9) Database Checkpoint - Verifies the contents of a database accessed by the application under test.Database checkpoint enables user to check the Content of the back end Database.

10) XML Checkpoint - Verifies the content of the .xml documents or .xml documents in Web pages and frames.

Thursday, 7 May 2015

QTP - 9 - About Connection Objects , recordsets - Its properties and methods

Connection Object : As we already know that the connection object is used for  database connection.We need the following code to connect to object :

Set conn = createobject(“Adodb.connection”)

Once the object is created, we need to set connection string to connect to the database. We can define a connection string with details of database including database provider, database, and user credentials for access.

Some useful methods and properties of connection object are as follows:

Properties:

conn.connectionstring – This property sets or returns the details used to create a connection to a data source. Includes details of driver, database,username and password.

conn.ConnectionTimeout – this defines the time  to wait for a connection to be established. If in the given time frame the connection is not establised it stops.

conn.provider – This sets or gets connection provider name.

conn.state – gives status whether connection is on or off.

commandtimeout - Set/get the no. of seconds to wait while attempting to execute a command . Default is 30- sec

Methods:

conn.open – opens a database connection based on the connection string provided. conn.Open connectionstring,userID,password,options

conn.Execute – execute the sql statement provided

conn.execute “Select * from table”

conn.close – This closes the adodb connection.


RecordSet Object:

Once a connection has been established, we can create recordset object to hold a set of record from database. A recorset consists of records and column

Set rs = createobject(“”Adodb.recordset”)

Some useful methods and properties of RecordSet Objects are as follows:

Properties:

BOF property returns True  if the current record position is before the first record in the Recordset,

EOF property returns True if the current record position is after the last record in the Recordset, otherwise it returns False. For a empty recordset,i.e no records in the recordset or empty recordset, value of BOF and EOF is false. So the property can be used in a loop to validate RecordSet does not return any records.

MaxCount Property returns the maximum value of records to be returned in a recordset.
rs.MaxCount = 20 will return 20 rows of data in recordset.


Methods:

rs.cancel – cancels an existing execution.

rs.clone – returns a clone of existing recorset and assigns to an object

set rsclone = rs.clone

rs.Close - closes instance of recordset

rs.open – opens a recordset based on query specified.

rs.open sqlquery, conn
where sqlquery is query executed and conn is connection object.

rs.move – moves the pointer in a recordset by specified count as defined in numrec

rs.move numrec, start.

Also  movenext,moveprevious, movefirst, movelast can be used to move to specified location in recordset.


Fields : it is used to point to any particular field . It represents any column of recordset object.

rs.fields.count gives number of items in the fields collection.

rs.field.item(i) returns specified item from the collection.

Wednesday, 6 May 2015

QTP - 8 -How to connect to a database ?

Before going to database , lets see two important concepts:

-> adodb connection ?

The ADO(ActiveX Data Objects) Connection object is used to create a connection to a data source. Through this connection, you can access and manipulate a database.

-> adodb recordset?

The ADO Recordset object is used to hold a set of records from a database table.To be able to read database data, the data should be loaded into a recordset.


To coonect to a database we need the following to be done :

1) create an instance of the database - here we create a object of the database
Eg :
set abc = Createobject("ADODB.Connection")

2) Create a connection string - It proides a string to connect to a particular database. It varies from database to database. Its usually provided by developer.
Connection string consist of data source and data provider. Datasource is the name of the database and provider is the driver of the database.

3) Create a record set - Its used to read the values from the tables. To fetch any data we need to create object of recordset

Eg  :
Set Rs = Createobject("ADODB.Connection")


4) Select the values by writing the queries.In record set we write queries to fetch data from database.
rs.Open "Select * from Table",oconn

5) use loop to display the data
Do while not Rs.EOF
' EOF hecks till end of data in recordset.
user =Rs.Fields("Username")
Pass =Rs.fields("Password")

'Here fields are used to get the data against each column, we give the olumn name

6) Clear the objects created :
Set Rs = Nothing
set Conn = Nothing

This is used to clear the llocated memory to the object.

-------------------------------------------------------------------------------------------------------------------------

Monday, 4 May 2015

QTP - 7 - About Local OR and Shared OR - Its Differences !!

Every action has its own repository known as per-action or Local Object repository. Shared OR is a warehouse where the repositories which are saved are accessible across all the actions.

Lets talk about their differences:

1). Local OR is accessible just to the particular action while Shared OR is accessible across all the actions.

2). Changes made to Shared OR is visible across all the actions in which it is hooked while changes made to local OR just remains in local action.

3) By default all the repositories are Local.

4) We prefer Local OR when the object's property is stable or static and Shared OR is preferd where the object's property is dynamically changing.

5) We can export our local repository to shared repository .

6) By default Shared Repository is non-editable but we can make it editable.