Forum Discussion

ilko01's avatar
ilko01
New Contributor
5 days ago

Need to add a variable to a string

During my test, I need to save a created file under a unique name, so, the next time system will not complain about identical file names. The best way is to append an Epoch timestamp to the new file name. I have a script generating the Epoch timestamp but have no clue how to add it while entering the file name into the Save As dialog.

The script to generate the Epoch timestamp is 

function findEpoch()
  {
    d = new Date();
    let timestamp = (parseInt(d.getTime()-d.getMilliseconds()/1000));
    Log.Message(timestamp);
    return timestamp;
  }

How can I pass this timestamp value to a Keyword Test and / or a script generated from that test?

  • use the 'run script routine' function in a keywordtest to run script code. 

    then use the function 'set variable value' and set that to 'last operation result'.

    the returned value from your script is now stored in your variable.

     

    Alternatively you could also set a variable in the script itself: