DDT.CurrentDriver Property

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

Use the CurrentDriver property to obtain the last DDTDriver object created with either ADODriver, ExcelDriver or CSVDriver methods of the DDT object. The property frees you from using a global variable to store the reference to the driver in a case when the driver creation and data processing code are located in different script routines (see Using DDT Drivers).

Declaration

DDT.CurrentDriver

Read-Only Property A DDTDriver object

Applies To

The property is applied to the following object:

Property Value

A DDTDriver object that provides scripting interface to the last created driver object.

Example

The code below creates a new Excel driver and gets access to its methods and properties via the CurrentDriver property.

JavaScript, JScript

function CurDriverExample()
{
  // Creates a driver
  DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");
   
  // Iterates through records
  while (! DDT.CurrentDriver.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(DDT.CurrentDriver.Name);
}

Python

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

VBScript

Sub CurDriverExample
  
  ' Creates a driver
  Call DDT.ExcelDriver("C:\MyFile.xls", "Sheet1")
   
  ' Iterates through records
  While Not DDT.CurrentDriver.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(DDT.CurrentDriver.Name)
  
End Sub

DelphiScript

function CurDriverExample;
begin

  // Creates a driver
  DDT.ExcelDriver('C:\MyFile.xls', 'Sheet1');
   
  // Iterates through records
  While Not DDT.CurrentDriver.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(DDT.CurrentDriver.Name);

end;

C++Script, C#Script

function CurDriverExample()
{
  // Creates a driver
  DDT["ExcelDriver"]("C:\\MyFile.xls", "Sheet1");
   
  // Iterates through records
  while (! DDT["CurrentDriver"]["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"]( DDT["CurrentDriver"]["Name"] );
}

See Also

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

Highlight search results