Item Method

Applies to TestComplete 14.93, last modified on October 12, 2021

Description

Use the Item method to obtain the object having the specified index in the object collection. To learn the total number of objects in the collection, read the Count property.

Declaration

aqObjIteratorObj.Item(Index)

aqObjIteratorObj An expression, variable or parameter that specifies a reference to an aqObjIterator object
Index [in]    Required    Integer    
Result An aqFileInfo, aqFolderInfo, aqDriveInfo, aqObjEvent, aqObjField, aqObjMethod, or aqObjProperty object.

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Index

Specifies the index of the desired object.

Result Value

The type of the returned object depends on the method or property that caused the creation of the aqObjIterator object:

Method/Property Generator Resulting object Item Meaning
aqDriveInfo.Files aqFileInfo Information about a single file from the drive’s root.
aqDriveInfo.Folders aqFolderInfo Information about a single folder from the drive’s root.
aqFileSystem.FindFiles aqFileInfo Information about a single file matching the specified search pattern.
aqFileSystem.FindFolders aqFolderInfo Information about a single folder matching the specified search pattern.
aqFileSystem.Drives aqDriveInfo Information on one of system drives.
aqFolderInfo.Files aqFileInfo Information about a single file of the folder.
aqFolderInfo.SubFolders aqFolderInfo Information about a single subfolder of the folder.
aqObject.GetEvents aqObjEvent A description of the object’s event.
aqObject.GetFields aqObjField A description of the object’s field.
aqObject.GetMethods aqObjMethod A description of the object’s method.
aqObject.GetProperties aqObjProperty A description of the object’s property.

Remarks

The Item method is the default method of the aqObjIterator object. You can skip the method’s name in your scripts to make them shorter. For example, the following two lines are equivalent to each other (the aqFileSystem.Drives statement returns a reference to the aqObjIterator object):

JavaScript, JScript

drv = aqFileSystem.Drives.Item(0);
drv = aqFileSystem.Drives(0);

Python

drv = aqFileSystem.Drives.Item(0)

VBScript

drv = aqFileSystem.Drives.Item(0)
drv = aqFileSystem.Drives(0)

DelphiScript

drv := aqFileSystem.Drives.Item(0);
drv := aqFileSystem.Drives(0);

C++Script, C#Script

drv = aqFileSystem["Drives"]["Item"](0);
drv = aqFileSystem["Drives"](0);

Example

The code below obtains the drives existing on your computer and posts their serial numbers to the test log.

JavaScript, JScript

function DriveSerialNumbersExample()
{
 var Fixed = 3;

 for (i = 0; i != aqFileSystem.Drives.Count; i++)
  if (aqFileSystem.Drives(i).DriveType == Fixed)
  {

   // Obtains the letter and the serial number of the specified drive
   var DrvLet = aqFileSystem.Drives(i).DriveLetter;
   var DrvNum = aqFileSystem.Drives(i).SerialNumber;
   // Posts the drive's letter and serial number to the test log
   Log.Message("The serial number of the " + DrvLet + " drive is: " + DrvNum);

  }
}

Python

def DriveSerialNumbersExample():
  Fixed = 3
  for i in range(0, aqFileSystem.Drives.Count):
    if aqFileSystem.Drives.Item(i).DriveType == Fixed:
      # Obtains the letter and the serial number of the specified drive
      DrvLet = aqFileSystem.Drives.Item(i).DriveLetter
      DrvNum = aqFileSystem.Drives.Item(i).SerialNumber
      # Posts the drive's letter and serial number to the test log
      Log.Message("The serial number of the " + str(DrvLet) + " drive is: " + str(DrvNum))

VBScript

Sub DriveSerialNumberExample
 Dim i, Fixed
 Fixed = 3

 For i = 0 to aqFileSystem.Drives.Count - 1
  If aqFileSystem.Drives(i).DriveType = Fixed Then

   ' Obtains the letter and the serial number of the specified drive
   DrvLet = aqFileSystem.Drives(i).DriveLetter
   DrvNum = aqFileSystem.Drives(i).SerialNumber
   ' Posts the drive's letter and serial number to the test log
   Call Log.Message("The serial number of the " + DrvLet + " drive is: " + IntToStr(DrvNum))

  End If
 Next
End Sub

DelphiScript

function DriveSerialNumberExample;
var i, Fixed, DrvLet, DrvNum;
begin
 Fixed := 3;

 for i :=0 to aqFileSystem.Drives.Count-1 do
  If (aqFileSystem.Drives(i).DriveType = Fixed) Then
  begin

   // Obtains the letter and the serial number of the specified drive
   DrvLet := aqFileSystem.Drives(i).DriveLetter;
   DrvNum := aqFileSystem.Drives(i).SerialNumber;
   // Posts the drive's letter and serial number to the test log
   Log.Message('The serial number of the ' + DrvLet + ' drive is: ' + IntToStr(DrvNum) );

 end;
end;

C++Script, C#Script

function DriveSerialNumberExample()
{
 Fixed = 3;

 for (i = 0; i != aqFileSystem["Drives"]["Count"]; i++)
 if (aqFileSystem["Drives"](i)["DriveType"] == Fixed)
  {

   // Obtains the letter and the serial number of the specified drive
   var DrvLet = aqFileSystem["Drives"](i)["DriveLetter"];
   var DrvNum = aqFileSystem["Drives"](i)["SerialNumber"];
   // Posts the drive's letter and serial number to the test log
   Log["Message"]( "The serial number of the " + DrvLet + " drive is: " + DrvNum );

  }
}

See Also

Count Property
Next Method
Skip Method

Highlight search results