ClickItem Object

Applies to TestComplete 14.92, last modified on September 16, 2021

Description

The ClickItem object is a helper object used to work with the following controls:

It provides access to a tested control's clickable items.

To get the ClickItem object, first get the collection of the tested control’s items by using the control's wItems property, and then use the collection’s Item property to get the needed item.

If the item that corresponds to the ClickItem object has child items, in turn, you can get access to them via the Items property.

Members

Example

The example below demonstrates how to get items and subitems of a ribbon control and simulate user actions on them. To work with the Paste item of the ribbon control, the test uses the ClickItem object. To get the object, it gets the Home item by using the wItems.Item property of the ribbon control and then uses the Items.Item property:

JavaScript, JScript

function TestRibbonControlItems()
{
  // Get the ribbon control
  var myRibbon = Sys.Process("MyRibbonApp").WinFormsObject("frmMain").WinFormsObject("ribbonControl");
  // Get the collection of ribbon control's items
  var ribbonItems = myRibbon.wItems;
  // Get the "Home" item of the ribbon control
  var home = ribbonItems.Item("Home");

  // Get the collection of the "Home" item’s subitems
  // And then get the "Paste" subitem
  var paste = home.Items.Item("Paste");
  // Simulate a click on the "Paste" subitem
  paste.Click();

  // Get the "Bold" subitem
  var bold = home.Items.Item("Bold");
  // Check the state of the “Bold” subitem
  if (bold.State == 0)
    Log.Message("Item 'Bold' is disabled")
  else
    Log.Message("Item 'Bold' is enabled")
  // Set the item's state to 'enabled'
  bold.Check(1);


}

Python

def TestRibbonControlItems():
   # Get the ribbon control
   myRibbon = Sys.Process("MyRibbonApp").WinFormsObject("frmMain").WinFormsObject("ribbonControl")
   # Get the collection of ribbon control’s items
   ribbonItems = myRibbon.wItems
   # Get the "Home" item of the ribbon control
   home = ribbonItems.Item["Home"]

   # Get the collection of the "Home" item's subitems
   # And then get the "Paste" subitem
   paste = home.Items.Item["Paste"]
   # Simulate a click on the "Paste" subitem
   paste.Click()

   # Get the "Bold" subitem
   bold = home.Items.Item["Bold"]
   # Check the state of the "Bold" subitem
   if (bold.State == 0):
     Log.Message("Item 'Bold' is disabled")
   else:
     Log.Message("Item 'Bold' is enabled")
   # Set the item's state to 'enabled'
   bold.Check(1)

VBScript

Sub TestRibbonControlItems()
  ' Get the ribbon control
  Set myRibbon = Sys.Process("MyRibbonApp").WinFormsObject("frmMain").WinFormsObject("ribbonControl")
  ' Get the collection of ribbon control’s items
  Set ribbonItems = myRibbon.wItems
  ' Get the "Home" item of the ribbon control
  Set home = ribbonItems.Item("Home")

  ' Get the collection of the "Home" item’s subitems
  ' And then get the "Paste" subitem
  Set paste = home.Items.Item("Paste")
  ' Simulate a click on the "Paste" subitem
  paste.Click

  ' Get the "Bold" subitem
  Set bold = home.Items.Item("Bold")
  ' Check the state of the "Bold" subitem
  If bold.State = 0 Then
    Log.Message("Item 'Bold' is disabled")
  Else
    Log.Message("Item 'Bold' is enabled")
  End If
    ' Set the item's state to 'enabled'
  bold.Check(1)

  …
End Sub

DelphiScript

procedure TestRibbonControlItems();
var myRibbon, ribbonItems, home, paste,bold;
begin
  // Get the ribbon control
  myRibbon := Sys.Process('MyRibbonApp').WinFormsObject('frmMain').WinFormsObject('ribbonControl');
  // Get the collection of ribbon control’s items
  ribbonItems := myRibbon.wItems;
  // Get the "Home" item of the ribbon control
  home := ribbonItems.Item('Home');

  // Get the collection of the "Home" item's subitems
  // And then get the "Paste" subitem
  paste := home.Items.Item('Paste');
  // Simulate a click on the "Paste" subitem
  paste.Click;

  // Get the "Bold" subitem
  bold := home.Items.Item('Bold');
  // Check the state of the "Bold" subitem
  if bold.State = 0 then
    Log.Message('Item ''Bold'' is disabled')
  else
    Log.Message('Item ''Bold'' is enabled');
  // Set the item's state to "enabled"
  bold.Check(1);

  …
end;

C#Script

function TestRibbonControlItems()
{
  // Get the ribbon control
  var myRibbon = Sys["Process"]("MyRibbonApp")["WinFormsObject"]("frmMain")["WinFormsObject"]("ribbonControl");
  // Get the collection of ribbon control's items
  var ribbonItems = myRibbon["wItems"];
  // Get the "Home" item of the ribbon control
  var home = ribbonItems["Item"]("Home");

  // Get the collection of the "Home" item’s subitems
  // And then get the "Paste" subitem
  var paste = home["Items"]["Item"]("Paste");
  // Simulate a click on the "Paste" subitem
  paste["Click"]();

  // Get the "Bold" subitem
  var bold = home["Items"]["Item"]("Bold");
  // Check the state of the "Bold" subitem
  if (bold["State"] == 0)
    Log["Message"]("Item 'Bold' is disabled")
  else
    Log["Message"]("Item 'Bold' is enabled")
  // Set the item's state to 'enabled'
  bold["Check"](1);


}

See Also

ItemCollection Object

Highlight search results