HP UFT or QTP: DataTable Methods, Properties and Related Interview Questions
August 26, 2018
HP UFT or QTP: DataTable Methods, Properties and Related Interview Questions
Welcome to this post! -“HP UFT or QTP: DataTable, DTSheet and DTParameter Methods, Properties and Related Interview Questions “.
If you are looking for latest HP UFT \ QTP Technical interview Questions, then you are at right place. This post “HP UFT or QTP DataTable, DTSheet and DTParameter Methods, Properties and Related Interview Questions ” consists of technical interview question which have been part of many interviews either external or internal. Usually these are assumed to be known in deep to check the logical solvency efficiency of the candidate and of course suitability for the project and company. Go ahead and enjoy reading…
This discussion will help you prepare well if you are going for the interview and you to understand the underlying concepts which supports the functioning of DataTable.
In the interview usually, you might be questioned in different ways like:
- What exactly is DataTable?
- Is DataTable is an object?
- Can we say it is a reserved object?
- Does DataTable represent a Keyword in QTP?
- How many types of DataTable are available in QTP?
- Can we export or import DataTable in QTP?
- How many sheet types can we have in our script?
- What is design-time and run-time DataTable? and so on.
In this post, we will discuss the QTP DataTable methods and properties, DTSheet methods and properties, and DTParameter object’s methods and properties associated with them.
DataTable Object Overview
Whenever we want to run our test cases via some data or in technical terms data driven test cases, we use DataTable.
So, what exactly is DataTable and how it helps us?
In HP UFT or HP QTP to run our data driven test cases we utilize the DataTable methods and properties to retrieve the values or set in the same DataTable. The data out test uses is actually stored in the design-time data table. This is usually displayed in DataTable pane.
This Data table has the similar features or characteristics of a MS Excel. We can store and retrieve data, as well use some formula-based cells in our test cases.
There are two ways of utilizing the test data
- Either you import test data excel sheet
- Or directly work with DataTable associated with your test action.
HP QTP or HP UFT have some reserved objects similar to reserved keywords. If you don’t know what I mean, Keywords in layman terms can be said as those words which are part of language and you can use them as their own usage syntax. Similarly, we have reserved objects which can be used in our test scripts to retrieve or set data.
Let’s checkout what all methods and properties do we have in the DataTable Object:
Associated Methods with DataTable Object
Method Name | Description | Syntax |
AddSheet | This method adds the specified sheet to the run-time data table. | DataTable.AddSheet(SheetName) |
DeleteSheet | This method deletes the specified sheet from the run-time data table. | DataTable.DeleteSheet SheetID |
Export | This method exports the DataTable to a new file in the specified location. | DataTable.Export(FileName) |
ExportSheet | This method exports a Specific Sheet of the DataTable in run-time. | DataTable.ExportSheet(FileName,SheetName) |
GetCurrentRow | This method returns the active row of the run-time data table of global sheet | DataTable.GetCurrentRow |
GetRowCount | This method returns the number of rows in the run-time data table of Global Sheet | DataTable.GetRowCount |
GetSheet | This method returns the specified sheet from the run-time data table. | DataTable.GetSheet(SheetID) |
GetSheetCount | This method returns the total number of sheets in the run-time data table. | DataTable.GetSheetCount |
Import | This method imports a specific external Excel file to the run-time data table. | DataTable.Import(FileName) |
ImportSheet | This method imports the specified sheet of the specific excel file to the destination sheet. | DataTable.ImportSheet(FileName, SheetSource, SheetDest) |
SetCurrentRow | This method sets the Focus of the Current row to the Specified Row Number | DataTable.SetCurrentRow(RowNumber) |
SetNextRow | This method sets the focus of the next row in the run-time data table | DataTable.SetNextRow |
SetPrevRow | This method sets the focus of the previous row in the run-time data Table. | DataTable.SetPrevRow |
Associated Properties with DataTable Object
GlobalSheet | This property returns the first sheet in the run-time Data Table (global sheet). | DataTable.GlobalSheet |
LocalSheet | This property returns the current (active) local sheet of the run-time Data Table. | DataTable.LocalSheet |
RawValue | This property retrieves the raw value of the cell in the specified parameter and the current row of the run-time Data Table. The raw value is the actual string written in a cell before the cell has been computed, such as the actual text from a formula. | DataTable.RawValue ParameterID [, SheetID] |
Value | This property is by default property of DataTable. This property retrieves or sets the value of the cell in the specified parameter and the current row of the run-time Data Table.
|
DataTable.Value(ParameterID [, SheetID])
or DataTable(ParameterID [, SheetID]) To set the value: DataTable.Value(ParameterID [, SheetID])=NewValue or DataTable(ParameterID [, SheetID]) =NewValue
|
DTSheet Object Overview
A DTSheet object is can be viewed as a sheet in run-time DataTable. Whenever we are working with tests scripts each action has its own DataTable Sheet associated with it. Plus, for complete test script there is only One Global Sheet. In general, we can access each of these sheets associated by clicking the different tabs shown in DataTable pane or with the help of following methods,
- AddSheet
- GetSheet
- GlobalSheet
- LocalSheet
Now let’s discuss what exactly Global and Data Table Sheets do.
Global Sheet
– When we want the data to be available for complete test actions i.e. each action can access same data then we should use Global Sheet DataTable. You can also control the number of test iterations in the settings for each action. The default name of this sheet is Global.
In relation HP ALM, you can use data awareness feature to store and access the data in Global Sheet. For details, see Data Awareness in HP ALM.
Action Sheets
– For every instance we add a new action to the test script, a new action sheet is added to the data table. When we want the data to be accessed dependent on the action we can store and retrieve the data using Action Sheet. Action sheets are also called Local Sheets, because they are associated to each action. The default name of this sheet is the action name itself.
In order to parameterize the test script, we can provide the input and output parameters in the test action’s properties and from there we can access and use them in same or other actions. We can also define the number of iterations for that action. This makes our action much flexible.
Associated Methods with DataTable Sheet or DTSheet Object
Methods | Description | Syntax |
AddParameter | This method adds the specified parameter (column) to the sheet in the run-time Data Table, sets the value of the first row to the specified value, and returns the parameter so that you can directly set or retrieve properties of the new parameter in the same statement. | DTSheet.AddParameter(ParameterName, Value) |
DeleteParameter | This method deletes the specified parameter from the sheet in the run-time Data Table. | DTSheet.DeleteParameter(ParameterID) |
GetCurrentRow | This method returns the row number of the current (active) row in the run-time Data Table sheet. | DTSheet.GetCurrentRow |
Value | This method is DataTable’s default property. This retrieves or sets the value of the cell in the specified parameter and the current row of the run-time Data Table. | DataTable.Value(ParameterID [, SheetID])
or DataTable(ParameterID [, SheetID]) To set the value: DataTable.Value(ParameterID [, SheetID])=NewValue or DataTable(ParameterID [, SheetID]) =NewValue
|
Associated Properties with DataTable Sheet or DTSheet Object
Properties | Description | Syntax |
Name | This property returns the name of the run-time data sheet. | DTSheet.Name |
DTParameter Object Overview
Similar to DataTable and DTSheet objects we have DTParameter. This lies at the bottom of the hierarchy of objects discussed so far. So, first is DataTable, then DataTable Sheet and then DTParameter.
The name is bit confusing for some as they might think it as passing parameters. But eventually it turns out to be defining the column names of the DataTable and storing the values. Later once our DataTable structure is defined and we want to refer the columns at that point we use the methods and properties provided with this object.
Following are the methods and properties defined for this object:
Associated Methods with DTParameter Object
Methods | Description | Syntax |
AddParameter | This method adds the specified parameter (column) to the sheet in the run-time Data Table, sets the value of the first row to the specified value, and returns the parameter so that you can directly set or retrieve properties of the new parameter in the same statement. | DTSheet.AddParameter(ParameterName, Value) |
GetParameter | This method retrieves the specified parameter from the run-time Data Table sheet | DTSheet.GetParameter(ParameterID) |
Associated properties with DTParameter Object
Properties | Description | Syntax |
Name | This property gets the name of the parameter (column) in the run-time Data Table. | DTParameter.Name |
RawValue | This property retrieves the specified parameter from the run-time Data Table sheet | DTParameter.RawValue |
Value | This property is DTParameter’s default property. This retrieves or sets the value of the cell in the current (active) row of the parameter in the run-time Data Table. | To find the value:
DTParameter.Value or DTParameter To set the value: DTParameter.Value =newvalue or DTParameter =newvalue
|
ValueByRow | This property retrieves the value of the cell in the specified row of the parameter in the run-time Data Table. | DTParameter.ValueByRow(RowNum) |
Conclusion
Before concluding on this topic “QTP or UFT DataTable Methods, Properties and Related Interview Questions (Latest UFT Technical Interview Questions)”, I would like to share with you some questions which are general and starting point of interviews. There some questions for which I haven’t discussed answers here but you can easily deduce them. So you can take it as your homework! 🙂
Few questions for you to think over and analyze :
- What exactly is DataTable?
- Is DataTable is an object?
- Can we say it is a reserved object?
- Does DataTable represent a Keyword in QTP?
- How many types of DataTable are available in QTP?
- Can we export or import DataTable in QTP?
- How many sheet types can we have in our script?
- What is design-time and run-time DataTable?
- What are the different ways of importing sheet in QTP or UFT?
- What are the different ways of exporting sheet in QTP or UFT?
- How can you get the name of new sheet created while in execution?
- How can you get the name of parameter you have created in the test run?
- is your global sheet can be exported too?
- Is there any way other than writing DataTable object’s methods, to import or export the external sheet and work on that?
- Can you parameterize the sheet?if yes then how?
- Can you parameterize the action using DataTable? if yes then how?
- Can you delete the Global sheet via Delete Method?
Last but not the least, if you would like to continue reading more on the QTP DataTable related interview questions, please follow the link
UFT Technical Interview Questions – Set 3
Huff!!! That was really long discussion. You also think same right. Well, this brings me to the end of the discussion where we have discussed some concepts as well as interview questions.I really hope you enjoyed reading the post. If you have any doubt on this please feel free to add your comment below.
And if you like to read more on UFT or QTP Technical Interview Questions please follow below links:
UFT Technical Interview Questions – Set 1
UFT Technical Interview Questions – Set 2
UFT Technical Interview Questions – Set 3
How to Download Resource From QC\ALM?
How to Upload Resource To QC\ALM?
How to Create Folder in QC or ALM using VBScript?
Or if you prefer General Interview Questions please follow below links:
UFT General Interview Questions – Part 1
UFT General Interview Questions – Part 2
If you would like to keep track of further articles on UFT (QTP). I recommend you to SUBSCRIBE by Email and have new UFT articles sent directly to your inbox.