Ask a Question

Copy and paste text from Variable


Copy and paste text from Variable

For an online application I have html fields which do not include the "max length" or "set text" methods. That leaves me with keying in characters to verify the max length allowed, which is not fast since the database limits are 4,000 characters. Is there a way within Keyword tests to copy the text of a project variable and then paste that into the field? Any other suggestions?




Hi @maumrm 


Are you using On Screen Action or Call Object Method operations? Call Object Method may have the methods you need.


If not, use the Object Spy in Advanced mode to list out all of the properties of the object, then you might be able to use a Call Object Method OR a code snippet using the SetAttributes method using a project variable as the value to set.

Community Hero



Is there a way within Keyword tests to copy the text of a project variable and then paste that into the field?

Most probably, you will have to use the RunCodeSnippet operation, and you may consider copying/pasting into field from clipboard as a possible option.
Something like this in pseudo-code:


var oField = ... // set a reference to the required field
oField.Click(); // this will set a focus to a field
oField.Keys("^[Home][P200]^![End][Del]"); // select all text in a field and delete it. "^A[Del]" might work as well
var strValue = getRandomString(5000); // your custom function that will return 5000 characters-long random string
var oClp = Sys.Clipboard; // preserve current value of clipboard
Sys.Clipboard = strValue; // stores strValue into clipboard. This line of code must immediately precede the next one to lower the chance of clipboard content corruption
oField.Keys("^V"); // paste from the clipboard via Ctrl-V shortcut
Sys.Clipboard = oClp; // restore clipboard
var strActualValue = oField.wText; // get actual value from a field
// do whatever verifications against strValue and strActualValue



  /Alex [Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
SmartBear Alumni (Retired)

Thanks to everyone in this thread!


Hi @maumrm! Please let us know if your question is solved - you can do this by marking the best reply as a solution. 

Sonya Mihaljova
Community and Education Specialist


I was able to do this by opening using the notepad as a TestedApp. A file with the text is opening, copied from the TestedApp, and then pasted into the application, then the TestedApp gets closed.

Showing results for 
Search instead for 
Did you mean: