DDTDriver Object

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The DDTDriver object is a DDT driver object that provides easy access to data stored in tables of ADO databases, Excel sheets or files holding data in comma-separated format (CSV files).

You can obtain a DDTDriver object in scripts by calling methods and properties of the DDT object.

The DDTDriver object provides unified access to data regardless of their storage format. You can work with data stored in an Excel sheet or a CSV file in the same manner as if this data was stored in a table. For more information on working with the DDTDriver objects, see Using DDT Drivers.

Note: Drivers that provide access to ADO databases have methods and properties of DDTDriver objects and contain a number of specific members. For information on them, see ADODriver Object.

Members

Example

The code below creates an Excel driver and then iterates through the records of the specified file using the properties and methods of the DDTDriver object.

JavaScript, JScript

function DDTDriverExample()
{
  // Creates a driver
  var Driver = DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");
   
  // Iterates through records
  while  (! Driver.EOF())
  {
  //Gets a value from the storage and posts it to the log
    Log.Message(Driver.Value(0));
    DDT.CurrentDriver.Next();
  }
   
  // Closes the driver
  DDT.CloseDriver(Driver.Name);
}

Python

def DDTDriverExample():
  # Creates a driver 
  Driver = DDT.ExcelDriver("C:\\MyFiles\\MyFile.xls", "Sheet1")
  # Iterates through records 
  while not Driver.EOF():
  # Gets a value from the storage and posts it to the log 
    Log.Message(Driver.Value[0])
    DDT.CurrentDriver.Next()
  # Closes the driver 
  DDT.CloseDriver(Driver.Name)

VBScript

Sub DDTDriverExample
  
  ' Creates a driver
  Set Driver = DDT.ExcelDriver("C:\MyFile.xls", "Sheet1")
   
  ' Iterates through records
  While Not Driver.EOF()
   
  ' Gets a value from the storage and posts it to the log
    Log.Message(Driver.Value(0))
    DDT.CurrentDriver.Next()
  WEnd
   
  ' Closes the driver
  DDT.CloseDriver(Driver.Name)
  
End Sub

DelphiScript

function DDTDriverExample;
var Driver;
begin

  // Creates a driver
  Driver := DDT.ExcelDriver('C:\MyFile.xls', 'Sheet1');
   
  // Iterates through records
  while Not Driver.EOF() do
  begin
  //Gets a value from the storage and posts it to the log
    Log.Message(Driver.Value(0));
    DDT.CurrentDriver.Next();
  end;
  
  // Closes the driver
  DDT.CloseDriver(Driver.Name);

end;

C++Script, C#Script

function DDTDriverExample()
{
  // Creates a driver
  var Driver = DDT["ExcelDriver"]( "C:\\MyFile.xls", "Sheet1" );
   
  // Iterates through records
  while  (! Driver["EOF"]())
  {
  //Gets a value from the storage and posts it to the log
    Log.Message(Driver["Value"](0));
    DDT["CurrentDriver"]["Next"]();
  }
  
  // Closes the driver
  DDT["CloseDriver"]( Driver["Name"] );
}

See Also

Using DDT Drivers
ADODriver Object
DDT Object
Data-Driven Testing - Basic Concepts
Data-Driven Testing - Retrieving Input Data From Storage

Highlight search results