Ask a Question

Calculate a dynamic value each test

SOLVED
Gra_Nap
New Contributor

Calculate a dynamic value each test

Hi there!

 

I would like to use a variable which should be calculated each test. 

For example, I would like to use a particular date (e.g. 01.05.2019).

I choose the "Keys" operation and set 01.05.2019 as Value. 

Next time I want to use another value (e.g. 01.06.2019) but it should be updated automatically. 

 

How can I set a rule to update my current value automatically and add one month each test like:

 

Thank you in advance!

 

 

4 REPLIES 4
AlexKaras
Community Hero

Hi,

 

Something like this (untested pseudocode):

var strDT = aqConvert.DateTimeToFormatStr(aqDateTime.AddMonths(aqDateTime.Now(), 1), '%d.%m.%Y');

<control>.Keys(strDT);

 

Regards,
  /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.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Thanks for the feedback!

 

Could you advise how a code which generates the required variable could be implemented in a KeywordTest?

Currently, I do not use scripts so I'll appreciate any assistance regarding the matter.

 

You can add bits of code to a keyword test with this:

https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/test-actions/run-code-snip...


Marsha_R
[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.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

You can also change the type of text you want to type from Constant~String to Code Expression.

 

[See attached]

cancel
Showing results for 
Search instead for 
Did you mean: