GetOptionNames Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use this method to get the names of all options in the current section. Option names are listed in a string where they are delimited by line breaks. To get the number of options in this collection, use the OptionCount property. To get the name of an option by its index in this collection, use the GetOptionName method.

Declaration

ProgObj.GetOptionNames()

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
Result String

Applies To

The method is applied to the following objects:

Result Value

The names of all options in the current section delimited by line breaks.

Example

The following code snippet obtains the values of the registry key and posts them to the Details panel of the test log.

JavaScript, JScript

function Test()
{

  var Key, Name, Count, Values;

  // Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey\\Subkey", HKEY_CURRENT_USER, AQRT_32_BIT, true)
  Name = Key.Name;
  // Determines how many values the key contains
  Count = Key.OptionCount;
  if (Count > 0)

    {
    // Posts the values to the Details panel
    Values = Key.GetOptionNames();
    Log.Message("The " + Name + " registry key contains the following values:", Values);
    }

}

Python

def Test():

  # Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey\\Subkey", HKEY_CURRENT_USER, AQRT_32_BIT, True)
  Name = Key.Name
  # Determines how many values the key contains
  Count = Key.OptionCount
  if (Count > 0):

    # Posts the values to the Details panel
    Values = Key.GetOptionNames()
    Log.Message("The " + Name + " registry key contains the following values:", str(Values))

VBScript

Sub Test

  Dim Key, Name, Count, Values

  ' Gets an object for the Windows system registry key
  Set Key = Storages.Registry("TestKey\Subkey", HKEY_CURRENT_USER, AQRT_32_BIT, True)
  Name = Key.Name
  ' Determines how many values the key contains
  Count = Key.OptionCount
  If Count > 0 Then

    ' Posts the values to the Details panel
    Values = Key.GetOptionNames
    Call Log.Message("The " & Name & " registry key contains the following values:", Values)
  End If

End Sub

DelphiScript

procedure Test();
var Key, Name, Count, Values;

begin

  // Gets an object for the Windows system registry key
  Key := Storages.Registry('TestKey\Subkey', HKEY_CURRENT_USER, AQRT_32_BIT, true);
  Name := Key.Name;
  // Determines how many values the key contains
  Count := Key.OptionCount;
  if Count > 0 then

    begin
    // Posts the values to the Details panel
    Values := Key.GetOptionNames;
    Log.Message('The ' + Name + ' registry key contains the following values:', Values);
    end;

end;

C++Script, C#Script

function Test()
{

  var Key, Name, Count, Values;

  // Gets an object for a Windows system registry key
  Key = Storages["Registry"]("TestKey\\Subkey", HKEY_CURRENT_USER, AQRT_32_BIT, true)
  Name = Key["Name"];
  // Determines how many values the key contains
  Count = Key["OptionCount"];
  if (Count > 0)

    {
    // Posts the values to the Details panel
    Values = Key["GetOptionNames"]();
    Log["Message"]("The " + Name + " registry key contains the following values:", Values);
    }

}

See Also

GetOptionName Method
GetSectionNames Method
OptionCount Property

Highlight search results