Code Navigation

Applies to TestComplete 15.63, last modified on April 23, 2024

TestComplete offers several ways to make navigation in script units simpler:

  • Use Code Explorer.

    Double-click a routine in the Code Explorer panel. TestComplete will automatically open the unit where the routine is declared, and position the cursor on the first line of this routine.

    Note: By default, the Code Explorer panel is hidden from TestComplete. To make the panel visible, select View > Select Panel from the TestComplete main menu, and then select Code Explorer in the resulting Select Panel dialog.
  • Use Ctrl+ clicks.

    If the Enable Ctrl-click navigation option is enabled, you can switch to the desired routine declaration by pressing Ctrl and clicking the routine call in the Code Editor.

    Suppose you have the following code:

    JavaScript, JScript

    function Main()
    {
      Test1();
      Test2();
      Test3();
    }

    Python

    def Main():
      Test1()
      Test2()
      Test3()
      

    VBScript

    Sub Main

      Test1

      Test2

      Test3

    End Sub

    DelphiScript

    function Main();
    begin
      Test1();
      Test2();
      Test3();
    end;

    C++Script, C#Script

    function Main()
    {
      Test1();
      Test2();
      Test3();
    }

    To switch to the Test3 routine quickly, press Ctrl and, without releasing it, click on the Test3 line of the Main routine. The Editor will position the cursor at the first line of the Test3 routine. If Test3 is located in another unit and this unit is specified in the USEUNIT / USES statement at the beginning of the current unit, TestComplete will open that unit in the Editor. You can also open another unit in the Editor by Ctrl-clicking the unit name.

    Note: Navigation by click does not work if the line you are going to Ctrl-click contains syntax errors.
  • Use the Go to Declaration command.

    To navigate to a routine, variable, constant or name mapping object declaration, right-click its name in script code and then click Go to Declaration.

  • Use the navigation history.

    If you use Ctrl+clicks or the Go to Declaration command, TestComplete retains the history of the insertion point movements. You can use the Navigate Back and Navigate Forward buttons on the Code Editor toolbar to move the insertion point to previous or more recent locations in the Editor. These buttons are unavailable until you use the Ctrl-clicking navigation or the Go to Declaration command. You can move through the navigation history by single steps only, in backward or forward directions. Using these buttons you can navigate through different units if a switch to the routine declared in another unit has been made.

    Note: The navigation history remain valid after you made a change to source code of your scripts. That is, TestComplete tracks changes in source code and modifies the navigate history automatically.
  • Use the routines list on the toolbar.

    You can switch to any routine declaration in the script unit that is opened in the current Code Editor window. Select the desired routine in the routine list on the Code Editor toolbar:

    TestComplete automatically will position the cursor at the first line of this routine in the Code Editor.

    Tip: The list of routines contains only the routines that are declared in the current script unit.

    For Python scripts, it also contains classes and their methods declared in the current script unit.

  • Use the Go to Error menu command.

    To quickly jump to a line that contains the first syntax error in a unit, right-click within the unit and choose  Go to Error from the context menu.

  • Bookmarks.

    To quickly switch between source lines, you can also use bookmarks. See the Bookmarks topic for more information.

  • Jump to a line by its number.

    To quickly locate a source line by its number, press Ctrl+G or select Edit > Go to Line Number from the TestComplete main menu and enter the desired line number into the Go to Line Number dialog.

  • Highlight all instances of the variable.

    To find out where a specific variable is used, double click its name anywhere in the code unit. TestComplete will highlight all the instances of that variable.

See Also

Code Editor
About Code Explorer
Editing Options
Finding and Replacing Text in Code Editor

Highlight search results