Clipboard Checkpoints

Applies to TestComplete 15.45, last modified on December 01, 2022

You use clipboard checkpoints to verify the current text content of the clipboard.

Requirements

The Clipboard Checkpoint script extension must be installed in TestComplete.

By default, the extension is installed automatically during the TestComplete installation. If you face any issues with creating clipboard checkpoints, select File > Install Script Extensions from the TestComplete main menu and verify that the Clipboard Checkpoint extension is installed and enabled:

Checking if the Clipboard Checkpoint script extension is installed and enabled

Click the image to enlarge it.

In addition, you may need to add the Clipboard Checkpoint to the TestComplete toolbar:

  1. Right-click the toolbar and then click Customize.

  2. In the resulting Customize dialog, switch to the Commands tab.

  3. Select Script Extensions in the category list, then select the Idle Script Extensions item, and drag it to the toolbar.

Adding the Clipboard Checkpoint command to a toolbar

Click the image to enlarge it.

Creating clipboard checkpoints

To get the current content of the system clipboard, use the Sys.Clipboard property. To verify the clipboard content, you can add appropriate text commands manually, or you can use the Create Clipboard Checkpoint dialog available during test recording and at design time:

During test recording

  1. Start recording a test.

  2. Select Clipboard Checkpoint from the Recording toolbar:

    Creating clipboard chekpoints when recording a test
  3. In the resulting dialog, specify the comparison conditions and the baseline text against which the clipboard content will be compared:

    Specifying the baseline text and the comparison conditions

    Click OK.

  4. TestComplete will automatically generate the comparison operations and add them to the recorded test.

At design time

In keyword tests

At design time, adding clipboard checkpoints to keyword tests by using the Create Clipboard Checkpoint dialog is not available. Add the verification commands to your tests manually. For example, you can use the If … Then operation:

  1. Open your keyword test for editing.

  2. Add the If … Then operation to the test. TestComplete will display the Operation Parameters dialog.

  3. In the dialog, specify the conditions that the operation will check:

    • Click the ellipsis button in the Value1 column.

      In the resulting dialog, select Code Expression from the Mode drop-down list and then enter Sys.Clipboard in the Value text box.

    • In the Condition column, specify the desired comparison condition, for instance, equal to.

    • Click the ellipsis button in the Value2 column.

      In the resulting dialog, select Constant from the Mode drop-down list and then select String from the Type drop-down list. In the Value text box, enter the baseline string against which the clipboard content will be compared.

    Creating clipboard checkpoints in keyword tests
  4. Click OK to close the dialog and to save the changes.

  5. To specify actions that your test will perform if the condition evaluates True, add them as the child operations of the If … Then operation.

  6. To specify actions to perform if the condition evaluates False, add the Else operation right after the If … Then operation. Then, add child operations to the Else operation.

In script tests
  1. Click Clipboard Checkpoint on the TestComplete toolbar:

    Creating clipboard checkpoint at design time
  2. In the resulting dialog, specify the comparison condition and the baseline text against which the clipboard content will be compared:

    Specifying the baseline text and the comparison conditions

    Click OK.

  3. TestComplete will generate the comparison code and display it in the Copy Text to Clipboard dialog. You can modify the code in the dialog if needed. Then, click Copy to copy the generated code to the clipboard and paste it to your script.

As an alternative, you can write the script code to verify the clipboard content manually. For example:

JavaScript

if( equal(Sys.Clipboard, "My Value"))
  // Success
else
  // Error

JScript

if( Sys.Clipboard == "My Value")
  // Success
else
  // Error

Python

if Sys.Clipboard == "My Value":
  # Success
  ...
else:
  # Error
  ...

VBScript

If Sys.Clipboard = "My Value" Then
  ' Success
Else
  ' Error
End If

DelphiScript

if Sys.Clipboard = 'My Value' then
  // Success
else
  // Error

C++Script, C#Script

if( Sys["Clipboard"] == "My Value")
  // Success
else
  // Error

Checkpoint source code

The clipboard checkpoint demonstrates how you can extend the TestComplete functionality with the script extension technology. You can find the checkpoint’s source code in the AQAScriptExtensions.tcx file that is located in the <TestComplete>\Bin\Extensions\ScriptExtensions folder. This file is a ZIP archive that has the .tcx extension. So, you can use any zip archiver to unpack files from it. For information on the extension’s files, see Pre-Installed Script Extensions.

See Also

About Checkpoints

Highlight search results