Clicking a Link in SysLink Controls in Desktop Windows Applications

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

While testing SysLink controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

There are several ways to click the specified link:

  • Use the ClickLink action of the Win32SysLink object, which is associated with all SysLink controls whose class names are listed in the project’s Object Mapping options. The ClickLink action has one parameter that specifies the index of the link contained in the SysLink control and simulates a mouse click over this link.

    The code below demonstrates how to click a link in the SysLink control located on the About Windows window (to invoke this window, select Help | About Windows from the main menu of the Windows Explorer) using the ClickLink action:

    JavaScript, JScript

    function main()
    {
      var SysLink;
        
      // Obtain the SysLink control
      SysLink= Sys.Process("Explorer").Window("#32770", "About Windows", 1).Window("SysLink", "", 1);
        
      // Click the link
      SysLink.ClickLink(0);
    }

    Python

    def Main():
        
      # Obtain the SysLink control
      SysLink= Sys.Process("Explorer").Window("#32770", "About Windows", 1).Window("SysLink", "", 1)
        
      # Click the link
      SysLink.ClickLink(0)

    VBScript

    Sub main
      Dim SysLink
        
      ' Obtain the SysLink control
      Set SysLink = Sys.Process("Explorer").Window("#32770", "About Windows", 1).Window("SysLink", "", 1)
         
      ' Click the link
      SysLink.ClickLink(0)
    End Sub

    DelphiScript

    procedure main;
    var SysLink;
    begin
      
      // Obtain the SysLink control
      SysLink := Sys.Process('Explorer').Window('#32770', 'About Windows', 1).Window('SysLink', '', 1);
           
      // Click the link
      SysLink.ClickLink(0);
    end;

    C++Script, C#Script

    function main()
    {
      var SysLink;
        
      // Obtain the SysLink control
      SysLink = Sys["Process"]("Explorer")["Window"]("#32770", "About Windows", 1)["Window"]("SysLink", "", 1);
      
      // Click the link
      SysLink["ClickLink"](0);
    }

  • Use the Click action of the Win32SysLinkItem object. To obtain this object, use the Link property of the Win32SysLink object. The Link property has one parameter that specifies the index of the link contained in the SysLink control and returns the Win32SysLinkItem object that corresponds to this link. The Click action simulates a mouse click over the link.

    Below is an example that demonstrates how you can click the same link using the Click action of the Win32SysLinkItem object:

    JavaScript, JScript

    function main()
    {
      var SysLink, SysLinkItem;
        
      // Obtain the SysLink control
      SysLink = Sys.Process("Explorer").Window("#32770", "About Windows", 1).Window("SysLink", "", 1);
      
      // Obtain the SysLinkItem object that provides a scripting interface for the link
      SysLinkItem = SysLink.Link(0);
      
      // Click the link
      SysLinkItem.Click();
    }

    Python

    def Main():
        
      # Obtain the SysLink control
      SysLink = Sys.Process("Explorer").Window("#32770", "About Windows", 1).Window("SysLink", "", 1)
      
      # Obtain the SysLinkItem object that provides a scripting interface for the link 
      SysLinkItem = SysLink.Link(0)
      
      # Click the link
      SysLinkItem.Click()

    VBScript

    Sub main
      Dim SysLink, SysLinkItem
        
      ' Obtain the SysLink control
      Set SysLink = Sys.Process("Explorer").Window("#32770", "About Windows", 1).Window("SysLink", "", 1)
      
      ' Obtain the SysLinkItem object that provides a scripting interface for the link
      Set SysLinkItem = SysLink.Link(0)
      
      ' Click the link
      SysLinkItem.Click
    End Sub

    DelphiScript

    procedure main;
    var SysLink, SysLinkItem;
    begin

      // Obtain the SysLink control
      SysLink := Sys.Process('Explorer').Window('#32770', 'About Windows', 1).Window('SysLink', '', 1);
      
      // Obtain the SysLinkItem object that provides a scripting interface for the link
      SysLinkItem := SysLink.Link(0);
      
      // Click the link
      SysLinkItem.Click;
    end;

    C++Script, C#Script

    function main()
    {
      var SysLink, SysLinkItem;
        
      // Obtain the SysLink control
      SysLink = Sys["Process"]("Explorer")["Window"]("#32770", "About Windows", 1)["Window"]("SysLink", "", 1);
      
      // Obtain the SysLinkItem object that provides a scripting interface for the link
      SysLinkItem = SysLink["Link"](0);
      
      // Click the link
      SysLinkItem["Click"]();
    }

See Also

Working With SysLink Controls in Desktop Windows Applications
ClickLink Action (SysLink Controls)
Click Action (SysLinkItem Objects)
Win32SysLinkItem Object
Link Property (SysLink Controls)

Highlight search results