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:
In addition, you may need to add the Clipboard Checkpoint to the TestComplete toolbar:
-
Right-click the toolbar and then click Customize.
-
In the resulting Customize dialog, switch to the Commands tab.
-
Select Script Extensions in the category list, then select the Idle Script Extensions item, and drag it to the toolbar.
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
-
Start recording a test.
-
Select Clipboard Checkpoint from the Recording toolbar:
-
In the resulting dialog, specify the comparison conditions and the baseline text against which the clipboard content will be compared:
Click OK.
-
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:
-
Open your keyword test for editing.
-
Add the If … Then operation to the test. TestComplete will display the Operation Parameters dialog.
-
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.
-
-
Click OK to close the dialog and to save the changes.
-
To specify actions that your test will perform if the condition evaluates
True
, add them as the child operations of the If … Then operation. -
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
-
Click Clipboard Checkpoint on the TestComplete toolbar:
-
In the resulting dialog, specify the comparison condition and the baseline text against which the clipboard content will be compared:
Click OK.
-
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.