https://www.qatechies.com

QTP or UFT and Vbscript: Technical Interview Questions (Latest UFT Interview Questions) Set 3

Latest Tosca,QTP,UFT,CodedUI Interview Questions

Latest UFT Technical Interview Questions and Answers (Latest Quicktest or UFT Interview Questions)- Set 3


Welcome to this post!-“Latest UFT Technical Interview Questions and Answers (Latest Quicktest or UFT Interview Questions)- Set 3″. If you are looking for latest HP UFT Interview Questions, then you are at right place. This post “Latest QTP Technical Interview Questions and Answers (Latest UFT Technical Interview Questions) – Set 3” consists of technical interview question which have been part of many interviews either external or internal. The post focuses on the UFT DataTable related interview questions. 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…

These latest QTP DataTable Technical Interview Questions and Answers (Latest UFT Technical Interview Questions) are related to DataTable,DTSheet and DTParameter objects. If you like to go through that post first before continuing with this one, then please follow the below link:

UFT DataTable Methods,Properties and Related interview questions

 


1. How to get Row Count and Column Count of Global or any Sheet?

 

Ans. We can use the getRowCount for counting the rows in the DataTable while GetParameterCount for counting the number of columns.

Below is the example:

SheetName: Global
Price Tax TotalPrice
20 10 22
30 10 33
40 10 44

 

rowCnt = DataTable.GetSheet("Global").GetRowCount

msgbox rowCnt      ' Displays 3


colCnt = DataTable.GetSheet("Global").GetParameterCount

msgbox colCnt         ' Displays 3

 

  ** in case of local also the answer would have remained same.


2. How to move cursor or pointer to current row in the DataTable?

 

Ans. We can use the SetCurrentRow method, for instance to set the row to 3,

Below is the example:

 

SheetName: Global
Price Tax TotalPrice
20 10 22
30 10 33
40 10 44

 

DataTable.SetCurrentRow(3)

rowVal = DataTable.Value("TotalPrice","Global")

‘print rowVal   'Displays 44


val_price = DataTable.Value("Price","Global")

‘print val_ price         'Displays 40

 


3. How to add new sheet in the run-time Data table?

 

Ans. We can use the AddSheet method while script is in execution as follows:

'This method adds the specified sheet to the run-time data table.
DataTable.AddSheet “myNewSheet”

 


4. How to add new parameter to the newly created sheet?

 

Ans. We can use AddParameter method for same as follows:

'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.

DataTable.GetSheet(”myNewSheet”).AddParameter “col1”,”value1”

 


5. Can we create the new sheet and parameter at the same time?

 

Ans. Yes we can do. This is possible because the AddSheet returns the reference of the newly created sheet via same AddSheet method in the same statement, which is why we don’t need to call GetSheet again to setup the parameters.

Below is the example:

DataTable.AddSheet(“sheetNew”).AddParameter “newParam”,”newValue”

6. How to delete a sheet from the QTP DataTable?

 

Ans. Deletion is possible from data table using the DeleteSheet method which deletes the specified sheet from the run-time Data Table.

Below is the example:

DataTable.DeleteSheet "sheetNew"

'or 

DataTable.DeleteSheet 1

7. By how many ways can we access the sheet in the QTP DataTable?

 

Ans. To access any sheet in the DataTable we have two options,

  1. By using the sheet name or
  2. By using the sheet index

Below is the example:

DataTable.GetSheet("sheetNew")


'Or


DataTable.GetSheet 1

*** We can also access the sheets via dtLocalSheet and dtgGlobalSheet variables.


8. How can we export a sheet present in the QTP DataTable?

 

Ans. For exporting the data sheet present in the DataTable, we can use the Export and Exportsheet methods.

The Export method saves the copy of the run-time Data Table in the specified location.

Below is the example:

DataTable.Export ("C:\TestData.xls")

 

On the other hand, ExportSheet method exports a specified sheet of the run-time Data Table to the specified or desired file and location.

But there are some points to be note here:

  1. If the desired named file does not exist, a new file is created and the specified or desired sheet is saved.
  2. If the current file exists, but the file does not contain a sheet with the specified or desired sheet name, the sheet is inserted as the last sheet of the file.
  3. If the current file exists and the file contains the specified sheet, the exported sheet overwrites the existing sheet.

 

Below is the example:

DataTable.ExportSheet "C:\TestData.xlsx" ,1

 


9. How to get the current row from your iterating data sheet? Or How will you know which row has been pointed to while debugging?

 

Ans. In this case, we can use the GetCurrentRow which returns the current (active) row in the first sheet in the run-time Data Table.

Below is an example:

rowVal = DataTable.GetCurrentRow ‘this will fetch the global sheet active row

mysheetrow= DataTable.GetSheet(“mysheetNew”).GetCurrentRow ‘this will fetch mysheet’s current or active row

 


10. In your data driven tests, you will require to import a complete test data file at once. Which method will you use?

 

Ans. For importing the test data file, we can use Import method which imports the specified or desired MS Excel file to the run-time Data Table.

But there are some points to be noted here:

  1. The imported table must match the test. The column names must match the parameters in the test, and the sheet names must match the action names.
  2. If we import an Excel table containing combo box or list cells, conditional formatting, or other special cell formats, the formats are not imported and the cell is displayed in the Data Table with a fixed value.

 

Below is the example:

DataTable.Import "C:\TestData.xlsx"

 


11. How can you import sheet in the QTP DataTable?

 

Ans. For importing the test data sheet, we can use ImportSheet method which imports the desired sheet of a specified file to the desired sheet in the run-time Data Table.

 

But there are some points to be noted here:

  1. The data in the imported sheet replaces the data in the destination sheet.
  2. The column headings in the sheet you import must match the Data Table parameter names in the action for which the sheet is being imported. Otherwise, your test or component may fail.
  3. The sheet you import automatically takes the name of the sheet it replaces.
  4. If you import an excel sheet containing combo box or list cells, conditional formatting, or other special cell formats, the formats are not imported and the cell is displayed in the Data Table with a fixed value.

 

Below is the example:

SheetName: logindetails{sheetID=1}
Userid Password
User1 Pwd1
User2 Pwd2
User3 Pwd3

 

DataTable.ImportSheet "C:\TestData.xlsx",1 ,"Login"
‘’This means we are importing sheet 1 from TestData file and loading into “Login” sheet of the Data Table.

 


12. Can we iterate through the Data sheet? Or How to iterate in data sheet of the data table?

 

Ans. We can use for-loop in the data sheet as shown below:

 

SheetName: Global
Price Tax TotalPrice
20 10 22
30 10 33
40 10 44

 

cnt=DataTable.GetSheet(“Global”).GetRowCount

For i=1 to cnt

DataTable.SetCurrentRow(i)

Price_val=DataTable.Value("Price","dtGlobalSheet")

Print Price_val

Next

 


13. How to add column in global sheet of QTP DataTable?

 

Ans. We can also use the globalsheet property to set the parameter to the global sheet.

Below is the example:

DataTable.GlobalSheet.AddParameter “col1”,”val1”

 

The above example uses property to set the column, we can also skip the property as shown below,

Datatable.AddParameter “col1”,”val1”

 


14. How to add column in local sheet of QTP DataTable?

 

Ans. We can use the LocalSheet property similar to global sheet to set the column name and value. The column name will be added to the local sheet and not to the desired local sheet. This is something called context dependency, as the action in which you are working on, only its local sheet will be considered for adding column and value.

 

Below is the example:

DataTable.LocalSheet.AddParameter “col1”,”val1”

 


15. How to add column in desired local sheet of QTP DataTable?

 

Ans. On the other hand, we can add the column in desired sheet using the GetSheet method.

Below is the example shown:

DataTable.GetSheet (“sheetNew”).AddParameter “newParam”,”newValue”

 


16. How many variables does data table object offers in QTP or UFT to access any sheet? OR How many types of SheetID are available in QTP DataTable?

 

Ans. There are four types of sheetID available. Below is the list:

  1. Index
  2. dtLocalSheet
  3. dtGlobalSheet
  4. desired sheet name

 


17.  How can we get the row value from the QTP DataTable?

 

Ans. We can use the value property to access the value of the parameter. This limits the traversing to desired parameter value as we don’t have any index supported with this property.

 

For example:

SheetName: mysheet
Price Tax TotalPrice
20 10 22
30 10 33
40 10 44

 

rowVal=DataTable.GetSheet(“mysheet”).GetParameter(“Price”).Value

 ‘ above will return first row value only.

‘Or

rowVal=DataTable.Value(“Price”,“mysheet”) ‘ this will return first row value only.

‘Or

rowVal=DataTable(“Price”,“mysheet”) ‘ this will return first row value only.

 


18. How to retrieve value from column by row number? Or How can you get the column value by row index? Or How can you get to row value if you know the row number? Or How can you get desired column value without iterating or defining loop?

Ans. We can use the ValueByRow property for accessing the row number or index of the desired column.

This property helps us to reach the row value directly without defining the loop and unnecessarily wasting memory.

Below is the example:

SheetName: mysheet
Price Tax TotalPrice
20 10 22
30 10 33
40 10 44

 

rowVal=DataTable.GetSheet(“mysheet”).GetParameter(“Price”).ValueByRow(2) 
‘ this will return second row value.

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.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

advanced-floating-content-close-btn
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5034726663464946 (adsbygoogle = window.adsbygoogle || []).push({});
advanced-floating-content-close-btn 
*************************** Do you want to learn TOSCA? Do you want to excel in Career? Try my New Courses: 1. Tricentis Tosca and Working with Excel   2. Tricentis Tosca and UI Automation Great News!!   Price has been slashed down for limited period of time.So Hurry!!! Click The Shown Links and Enjoy Learning. ***************************
 
error: Content is protected !!