Cycle does not include a step to add data to the OS Clipboard

Cycle does not include a step to add data to the OS Clipboard

Problem

Cycle has steps that copy, assign to variable, and clear OS clipboard contents but does not contain any steps to copy data to the OS clipboard.

Cycle can enter values into the focus application but that is done character by character. For long strings that can add unnecessary processing delays.

Solution

With Cycle's ability to execute Groovy scripts it is possible to use Groovy functionality to copy Cycle data to the OS clipboard. Once the data is copied to the clipboard it can be pasted all at once avoiding the character by character entry.

Example

The example Groovy syntax is responsible for copying the contents of a variable named "str" to the OS clipboard. The value of the variable will come from Cycle.

clipboard.groovy

import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
import java.awt.datatransfer.StringSelection

Toolkit toolkit = Toolkit.getDefaultToolkit()
Clipboard clipboard = toolkit.getSystemClipboard()
StringSelection strSel = new StringSelection(str)
clipboard.setContents(strSel, null)

The example Scenario assigns a value to a variable named "str". Then executes the Groovy script clipboard.groovy which uses the value in "str". The script is responsible for copying the value of "str" to the OS clipboard. Finally, to validate, the Feature opens notepad and executes the paste shortcut for the clipboard contents.

Scenario: Copy to clipboard
Given I assign "Tryon Solutions is the proud developer of Cycle automated testing software, for individuals and teams who want to regularly test their supply chain systems and processes to identify errors before production is impacted." to variable "str"
When I execute Groovy script "scripts\clipboard.groovy"
Then I execute process "notepad.exe"
And I wait 1 seconds
And I press keys "CTRL+V"

To see the performance difference execute the following Scenario

Scenario: Enter Variable
Given I assign "Tryon Solutions is the proud developer of Cycle automated testing software, for individuals and teams who want to regularly test their supply chain systems and processes to identify errors before production is impacted." to variable "str"
When I execute process "notepad.exe"
Then I wait 1 seconds
And I enter $str

 

    • Related Articles

    • Common Cycle License Questions

      (This article is applicable to Cycle 2.5.0 and earlier versions) Why can't I get a Cycle license on my machine? There are a few possible blockers to your local Cycle client being able to connect to the license server and check out your license. ...
    • My SSH terminal connections are failing in Cycle with error adding to known hosts file.

      Problem My SSH terminal connections are failing in Cycle with error adding to known hosts file. Solution SSH terminal connections use a known_hosts file stored in the user’s home directory to store server information when you establish an SSH ...
    • “Unexpected Response from the license server. Status code 590...” while logging into Cycle

      (This article is applicable to Cycle 2.5.0 and earlier versions) Problem  I receive the error: "Unexpected Response from the license server. Status code 590..." while trying to log into Cycle. Solution A status code 590 occurs when Cycle is unable to ...
    • My web-based Cycle tests are failing.

      Problem My browser-based Cycle Features are failing. Solution Check that the following common mistakes are not causing your failures: 1. Opening the browser first Any browser-based Steps in Cycle should be preceded in their Scenario with: I open ...
    • Terminal Hangs or Does Not Open

      Problem My terminal appears to hang or returns unexpected results when using the Cycle step to open a terminal connection. Potential Issues and Solutions There are several common issues that can cause failures when opening a terminal in your Cycle ...