Search code examples
javascriptkantu

Kantu UI.Vision - Use date+time as variables for the captureEntirePageScreenshot command file name


I'm attempting to use Kantu UI.Vision to take screen captures of a page URL at regular intervals while passing the current date and time of the capture to the file name (for each screen capture file name like this: dd-mm-yyyy__HH-mm-ss.png)

I don't have much experience with JS and i can't get the macro to calculate the current date-time before each capture.

Anyone did it/know how to do it?


Solution

  • Eventually I found a solution...

    Begin macro with

    Command: executeScript_Sandbox

    Target: var d = new Date(); m = d.getDate()+"-"+(d.getMonth()+1)+"-"+ d.getFullYear()+"_"+ d.getHours()+"ː" + d.getMinutes() + "ː" + d.getSeconds(); return m

    Value: timestamp

    Then, when effectuating the screen capture command use the timestamp variable in the filename:

    Command: captureEntirePageScreenshot

    Target: Screenshot_${timestamp}.png