490 likes | 630 Views
Synchronization Points Lesson. Data Table Functions. Why Data Table Methods. To use Data Table methods, we need to consider Data Table as an object. Read the data placed in another action Data Table. . Randomized the data reading process, which otherwise reads in a sequential process. .
E N D
Synchronization Points Lesson Data Table Functions
Why Data Table Methods To use Data Table methods, we need to consider Data Table as an object. Read the data placed in another action Data Table. Randomized the data reading process, which otherwise reads in a sequential process. Change the Test Data placed in Data Table at run-time. Import Test Data sets available in excel format to the Data Table. By using Data Table methods, we can: 5 4 3 2 1
Description of Data Table Object Data Table Run - Time Note: Changes to the run-time DataTable object are reflected in the test results, but the design-time Data Table is not affected. Properties Methods
Types of Data Table Object Object Model DataTable DTSheet DTParameter
Description of Data Table DataSheet DataParameter
List of Associated Methods and Properties - DataTable Associated Properties and Methods Value Property Raw Value Property Set Next Row Method Set Prev Row Method Set Current Row Method Get Row Count Method Get Current Row Method Import Method Import Sheet Method Get Sheet Method
Data Table Object - Value Property • The Value is a default property of the Data Table. It retrieves or sets the value of the cell in the current row of the run-time Data Table. DataTable.Value(ParameterID ,[SheetID]) Syntax to Retrieve: DataTable.Value(ParameterID [,SheetID])=NewValue Syntax:
Example of Value Property – Setting the Data Value Run - Time Run - Time
Data Table Object - RawValue Property The raw value property retrieves the raw value of the cell in 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 formula placed in the cell. DataTable.RawValue(ParameterID ,[SheetID]) Syntax: Return Type: String
Data Table Object – SetNextRow Method The SetNextRow method sets the row after the current row as new current row in the run-time Data Table. DataTable.SetNextRow Syntax: Note: A row can be set only if it contains at least one value. If this method is applied on the last row of the Data Table, the first row of the Data Table is set as the new current row. Return Type: None
Data Table Object – SetPrevRow Method The SetPrevRow method sets the row above the current (active) row as the new current (active) row in the run-time Data Table. Note: DataTable.SetPrevRow Syntax: If the current row is the first row in the Data Table, applying this method sets the last row in the Data Table as the new current row. Return Type: None
Example – SetPrevRow Method Note: When the cursor is placed in the first row of the Data Table and the method is applied, the cursor goes to the last row of the Data Table.
Data Table Object – SetCurrentRow Method The SetCurrentRow method sets the specified row as the current row in the run-time Data Table. DataTable.SetCurrentRow(RowNumber) Syntax: Return Type: None
Data Table Object – GetRowCount Method The GetRowCount method returns the total number of rows in a column in the run-time Data Table Global sheet. DataTable.GetRowCount Syntax: Return Type: Number
Data Table Object – GetCurrentRow Method The GetCurrentRow method returns the current row in the run-time Data Table global sheet. DataTable.GetCurrentRow Syntax: Return Type: Number
Data Table Object – Import Method The Import Method imports the specified Microsoft Excel file to the run-time Data Table. Its argument is a string which is the full path of the Excel table to be imported. This file can be present in the File System or in the Quality Center Path. DataTable.Import(FileName) Syntax: Note: Note: Note: File to be imported shouldn't be opened while executing the test script. Verify that the column names are matching to the parameters in the test, and the sheet names are matching to the action names. QTP doesn’t give an error while importing when there is a mismatch. But, it may not give the indented results while reading the data with parameter names. Return Type: None DataTable.Import(“C:\Data Tables\Table1.xls”) Example:
Data Table Object – ImportSheet Method The Import Sheet 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. Syntax: DataTable.ImportSheet(FileName, SheetSource, SheetDest) Return Type: None Example: DataTable.ImportSheet("C:\Contact.xls" ,”Sheet1” ,“Action1“)
GlobalSheet and LocalSheet DTSheet Object Data Table Commands Note: You can also use the method “DataTable .GetSheet” to get the DTSheet object. GlobalSheet / LocalSheet Properties
Global Sheet Property The Global sheet property returns the object of first sheet in the run-time Data table, which is the global sheet. DataTable.GlobalSheet Syntax: Return Type: DTSheet Example: Set objGlobal=DataTable.GlobalSheet
Local Sheet Property The local sheet property returns the current active local sheet of the run-time Data table. DataTable.LocalSheet Syntax: Return Type: DTSheet Example: Set objLocal=DataTable.LocalSheet
GetSheet Method The Get Sheet method of Data Table object returns the specified sheet from the run-time Data table. Its syntax and examples are shown on screen. Syntax: DataTable.GetSheet (SheetID) Return Type: DTSheet Example1: SetobjGlobal= DataTable.GetSheet(1) Example2: Set objLocal = DataTable.GetSheet(“Action1")
List of Commonly Associated Methods and Properties - DTSheet Commonly Associated Properties and Methods SetNextRow Method SetPrevRow Method SetCurrentRow Method GetCurrentRow Method GetRowCount Method GetParameter Method GetParameter Count Method Name Property
Common Methods in DataTable and DTSheet Objects DataTable Common Methods DTSheet SetNextRow SetPrevRow SetCurrentRow GetCurrentRow
GetRowCount This method returns the number of rows in the longest column of given DT Sheet. DTSheet.GetRowCount Syntax: Return Type: Number
Name Property The Name property returns the name of the data sheet at run-time. DTSheet.Name Syntax: Return Type: String
GetParameter CountMethod Parameter in Data Table is similar to column in the excel sheet. The Get Parameter Count method returns the total number of parameters in the Data sheet at run-time. . DTSheet.GetParameterCount Syntax: Return Type: Number
GetParameter Method The Get Parameter method retrieves the specified parameter from data sheet at run-time. . DTSheet.GetParameter(ParameterID) Syntax: Return Type: DTParameter Object
List of Properties Associated with DT Parameter Associated Properties Name Value ValueByRow RawValue
Name Property (DTParameter Object) The Data parameter object’s name property returns the name of a specified column in the run-time Data Sheet. . DTParameter.Name Syntax: Return Type: String
Value Property The Value property is the default property of DT Parameter object. It retrieves or sets the value of the cell in the current active row of the parameter in the run-time Data table. . DTParameter.ValueorDTParameter Syntax to Retrieve: Note: Note: This method returns the computed value of the cell. For example, if the cell contains a formula, this property returns the computed value by replacing variables in the formula with the actual values. Also, the word Value in the statement above can be omitted, because it is the default property for this object. Syntax to Set: DTParameter=newvalue
Example – Value Property DataParameter Object To Retrieve: To Set:
ValueByRow Property The Value By Row property sets and retrieves value in the specified row of the parameter in the run-time Data sheet. . DTParameter.ValueByRow(RowNum) Syntax: Variant Return type: Example: DTParameter.ValueByRow(4)
RawValue Property The RawValue property returns the raw value of the cell in the current row of the parameter in the run-time Data Table. . DTParameter.RawValue Syntax: Return Type: String