You are on page 1of 14

Advanced QTP:

External Data Sheet


External Data Sheet

External Data Sheet Session: Agenda


• Introduction to External Data Sheet

• Calling External Data Sheet

– Keyword View
• Importing an Data Sheet
• Importing an Database
– Expert View
– Various functions available in QTP for data sheet

• Exporting Data Sheet

• Session Wrap-Up

Accenture Confidential. For Internal use Only. 2


External Data Sheet

External Data Sheet – Why do we need it?

• QTP has a inbuilt Data table that can be used for parameterizing tests
and for output operation.

• Using an external Excel file, these operations can be performed by the


user and saved and used later for some other tests.

• This allows the contents of the data table used in QTP to saved in
another Excel file.

• Allows the complete Database to be stored in an Excel sheet.

• Provides Data table functions to call the sheets using programming


through the Expert View.

Accenture Confidential. For Internal use Only. 3


External Data Sheet

Importing a Data sheet in Keyword View


• The user will initially have to create the Excel sheet and store it.

• In the application the user calls this file


by right-click on the Data table
and select File>Import from File

• The contents of the sheet shall


appear in the Data table of QTP.

Note: It becomes important to provides the Column name similar to the parameter name given to the action that is
being parameterized.

Accenture Confidential. For Internal use Only. 4


External Data Sheet

Importing a Data sheet in Keyword View


• In the below example it can be observed that the names given to the
parameter and the column name is the same.

Parameter
Name
Column
Name

Accenture Confidential. For Internal use Only. 5


External Data Sheet

Importing a Data sheet in Keyword View

• This is applicable to all the parameters that have been declared in the
Excel sheet for QTP.

• This basically helps QTP to synchronize the terms else if the names
are different then test run might fail with an parameter not found error.

• We can also perform the parameterizing operation using Global and


Local parameters. We will have to declare terms in two sheets in the
Excel file and when it is imported both the sheets are copied.

• The contents of the first sheet can be used for Global parameter and
that of the second can be for local.

Note: If in an Excel file you have declared parameters in more than two sheets then contents of first two sheets shall be
copied by default and not of the third. Since in Data Table by default there are only two sheets available Global and
Action1. To copy more than two sheets of Excel file the user will have to create more actions in the test.

Accenture Confidential. For Internal use Only. 6


External Data Sheet

Importing a Data sheet in Keyword View


• It is also possible to import a single sheet rather the whole Excel file in QTP.
• This becomes helpful as if we want to import parameters for the Global sheet
from an different Excel file and for the Local from another Excel file.
• In the application the user calls this file by right-click on the Data table and
select Sheet>Import>From File. Now from the Excel file user will have to
specify which sheet he wants to import.

• During the above operation one needs to be careful that current sheet in the
QTP Data table is empty else the contents of the calling Excel sheet shall
overwrite the current contents. Also this can be applicable for Global and local
parameter operation in QTP, by selecting the appropriate sheets.

Accenture Confidential. For Internal use Only. 7


External Data Sheet

Importing a Database in Keyword View


• The user can also import the contents of the Database into the Data
table of QTP by right-clicking on the Data table and select
Sheet>Import>From Database.

• Now user will have to create an SQL statement manually and create a
connecting string as shown below and click finish.

Accenture Confidential. For Internal use Only. 8


External Data Sheet

Importing a Database in Keyword View


• The Database will get imported into the Data table of QTP as shown
below

• These contents can further be exported to an Excel file.

Accenture Confidential. For Internal use Only. 9


External Data Sheet

Exporting a Data sheet in Keyword View


• The contents of the Data table can be exported to an external Excel file as the
parameters initialized in the table can be made useful in any other test.
• The user will have right-click on the data table and select File>Export. You will
get an option to either save in a new Excel file or in an already existing file.

• For an existing Excel QTP will overwrite the contents of the data table however
in the process will ask the user if he wants to do so.
• Similarly the user can also export an single sheet from the data table into an
Excel file.
• For an existing Excel file if the sheet names are similar to that of the data table
then QTP will overwrite the contents of the data table however in the process
will ask the user if he wants to do the same.
• Generally the exported contents get stored into an new sheet other than the
existing sheets in the Excel file.
• User can also export the contents of the Global and Local data sheet either into
the same Excel file in adjacent sheets or in different Excel files.
Accenture Confidential. For Internal use Only. 10
External Data Sheet

Expert View for importing and exporting Data sheet


• In the expert view user can utilize the functions available in QTP for
both importing and exporting sheets .
• The function that is used to perform this operation in QTP is
“DataTable.”, on typing this in the expert view the user gets all the
related functions for working on external datasheet

• In the above example the DataTable function has been used to


parameterize the action and also this works as Global and Local
parameters with the help of the looping structure.
• The functions that are available in QTP are mentioned ahead.

Accenture Confidential. For Internal use Only. 11


External Data Sheet

Expert View for importing and exporting Data sheet


QTP Function Description

Add Sheet/Parameter Adds specified sheet or parameter to the run-time Data Table and returns the sheet and
method parameter respectively to set the properties directly.

Delete Sheet/Parameter Deletes the specified sheet/parameter from the run-time Data Table.

Export/Import Method Saves/ Copies a copy of the run-time Data Table to/from the specified location

ExportSheet Method Saves copy of a sheet in the specified location. If does not exists then creates one else
overwrites the existing sheet.

ImportSheet Method Imports a sheet of a specified file to a specified sheet in the run-time Data Table. The data in
the imported sheet replaces the data in the destination sheet..

GlobalSheet Property Returns the Value of the first sheet of the run-time Data Table which is known as the Global
sheet.

LocalSheet Property Returns the current (active) local sheet of the run-time Data Table.

Get/SetCurrentRow Method Retrieves the current row in the active sheet that is being used/Sets the row specified as the
for Data Table active row in the data table.

Get/SetCurrentRow Method Retrieves the current row in the active sheet that is being used/Sets the row specified as the
for Data Sheet active row in the data table sheet.

Accenture Confidential. For Internal use Only. 12


External Data Sheet

Questions?

Q & A….

Accenture Confidential. For Internal use Only. 13


External Data Sheet

Session Wrap-up
• External Data Sheet allows the user to call a external Excel file to
perform action with user defined
• External Data Sheet also allows the user to just call a single sheet in
the Excel file and not the complete file as a whole.
• Using this, contents of the Data table in QTP can be exported to an
external Excel file and can be made use of as parameters for some
different test.
• Data base contents can be imported and can be saved in an Excel file.
• Data.Table function used in Expert View helps to import, export, add,
delete sheets etc.

Accenture Confidential. For Internal use Only. 14

You might also like