DDT Object

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

Description

TestComplete includes special program objects that let you easily access data stored in an Excel sheet, CSV file or in an ADO database table. These objects are called drivers. They are typically needed to perform data-driven tests, however, you can also use them to retrieve data from the mentioned storages.

The DDT object is used to create drivers for ADO database tables, Excel sheets and files holding comma-separated data (CSV file). Its methods return special “driver” objects that have access to values stored in the mentioned data storages.

Note: The object is only available if the Data-Driven Testing plugin is installed in TestComplete. See Using DDT Drivers.

Members

Example

The TestProc procedure connects to the specified database, retrieves information about the text of the command used by the database’s table, posts this command text to the test log, and then closes the connection to the database.

Notes:

JavaScript, JScript

function TestProc()
{
 // Specify the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 15 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
  // Specify the name of the table
  var tName = "orders";
  // Obtain the ADO Command text
  var cText = DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText;
  // Post this command text to the test log
  Log.Message(cText);
  // Close the connection to the specified database
  DDT.ADODriver(ConStr, cText).ADOConnectionObject.Close();
}

Python

def TestProc():
  # Specify the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + \
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb"
  # Specify the name of the table
  tName = "orders"
  # Obtain the ADO Command text
  cText = DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText
  # Post this command text to the test log
  Log.Message(cText)
  # Close the connection to the specified database
  DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close()

VBScript

Sub TestProc
   ' Specify the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
  "Data Source=C:\Users\Public\Documents\TestComplete 15 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb"
  ' Specify the name of the table
  tName = "orders"
  ' Obtain the ADO Command text
  cText = DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText
  ' Post this command text to the test log
  Log.Message(cText)
  ' Close the connection to the specified database
  DDT.ADODriver(ConStr, tText).ADOConnectionObject.Close
End Sub

DelphiScript

function TestProc;
var ConStr, tName, cText;
begin
  // Specify the connection string
  ConStr := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
  'Data Source=C:\Users\Public\Documents\TestComplete 15 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb';
  // Specify the name of the table
  tName := 'orders';
  // Obtain the ADO Command text
  cText := DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText;
  // Post this command text to the test log
  Log.Message(cText);
  // Close the connection to the specified database
  DDT.ADODriver(ConStr, cText).ADOConnectionObject.Close();
end;

C++Script, C#Script

function TestProc()
{
  // Specify the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 15 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
  // Specify the name of the table
  var tName = "orders";
  // Obtain the ADO Command text
  var cText = DDT["ADODriver"]( ConStr, tName )["ADOCommandObject"]["CommandText"];
  // Post this command text to the test log
  Log["Message"](cText);
  // Close the connection to the specified database
  DDT["ADODriver"](ConStr, cText)["ADOConnectionObject"]["Close"]();
}

See Also

Using DDT Drivers
DDTDriver Object
Data-Driven Testing
Using Scripts for Data-Driven Testing

Highlight search results