Ask a Question

Passing a manipulated date to a keyword test in TestComplete


Passing a manipulated date to a keyword test in TestComplete

Forgive me if this is covered already somewhere but I couldn't find the solution. I will try outline the problem:


I have a date on a field into which I want to place todays date - 10 years

I have a script that will generate this value for me


My question is how or where do I call this script value so that the date field  populates with this new date value? 

Community Hero

In keyword tests you can use Code Snippet to use a script call and you would assign the value from the script to the field where you want it.

[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.

1. make sure that the script generates the desired date == returns that date output as a result of running the script routine (probably as a string data type)

2. drag that script routine into your keyword test

3. drag in an "on screen action" into the keyword test workspace immediately below the "run script routine" 

 3.1 Follow the new pop up window to "drag&drop" or "ctrl-shift-a" select the on screen element where you wish to input the date

 3.2 You will probably want to use the "SetText" or "Keys" operations to input the desired date into your desired on screen element. (over simplified explanation: Keys == actual key presses, whereas SetText == literally sets the text)

 3.3 Now you need to provide the value that you want to either "SetText" or "Keys" - should be by default set to Constant Text mode, but you can edit this to be "Last Operation Result"  (select the three dots on the farthest right hand side of the value panel, click around until you see that option).


Justin Kim

Thanks to you both for this. It has helped a lot! Much appreciated.

Showing results for 
Search instead for 
Did you mean: