captureDesktopScreenshot adding in screen name variable with date and time error

Hi @admin

I tried this command capturedesktopscreenshot and in the path I add some variables with date and time and when i add variables this command don’t work

This is my code

captureDesktopScreenshot | C:\Users\Windows\Desktop\screen${Date}_${Time}.png |

This is the error

Failed to captureDesktop, please confirm directory exists at 'C:\Users\Windows\Desktop

The path exist and it is correct, if i remove the variables from the name of screenshot it works

Have a nice day

RTFM
https://a9t9.com/kantu/docs/selenium-ide/capturescreenshot

Chrome extensions can not access the file system. Instead, the screenshot is saved internally and available in the “Screenshot tab”. From there you can “download” it as an image file (PNG) if needed.

I use firefox and the command save in hard drive the screenshot png only if I do not add any variable in file name.

I need timestamp in image name but i can not add any variable.

Ok. Let me clarify.
You cannot use PATH. But you can use variables.
Here is a piece of my code:

You know what. I am completely wrong here. I’m sorry about misinformation. My bad.
I missed the “desktop” part. This is a new command that uses external XModules.
Thus I’m not familiar with it. Since its new it might be there could be errors with variables or the lack of their support at all.
Again sorry for misleading you.

@newuserkantu What is the content of your date and time variables? Maybe they contain a character that is not allowed in the file system?

I tested captureDesktopScreenshot with a variable, and it works file. => Screenshot saved as “test_test2.png”.

capturedesktopscreenshot1

1 Like

Hi @Plankton

This is the code

{
  "Name": "_Screenshot",
  "CreationDate": "2019-4-22",
  "Commands": [
    {
      "Command": "storeEval",
      "Target": "var d=new Date(); d.getDate()+'-'+((d.getMonth()+1))+'-'+d.getFullYear();",
      "Value": "Date"
    },
    {
      "Command": "storeEval",
      "Target": "(new Date().getHours()+\" : \" + new Date().getMinutes() + \" : \" + new Date().getSeconds()) ",
      "Value": "Time"
    },
    {
      "Command": "store",
      "Target": "screen-${Date}-${Time}.png",
      "Value": "Screen"
    },
    {
      "Command": "bringBrowserToForeground",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://www.google.com",
      "Value": ""
    },
    {
      "Command": "pause",
      "Target": "1000",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "str = \"${Screen}\"; str= str.replace(/([^a-z0-9]+)/gi, '_'); str",
      "Value": "Screen2"
    },
    {
      "Command": "echo",
      "Target": "${Screen} - ${Screen2}",
      "Value": ""
    },
    {
      "Command": "captureEntirePageScreenshot",
      "Target": "${Screen2}",
      "Value": ""
    },
    {
      "Command": "localStorageExport",
      "Target": "${Screen2}",
      "Value": "#DeleteAfterExport"
    }
  ]
} 

I tried with captureEntirePageScreenshot and localStorageExport and save the screenshot but do not export, it’s possibile a my mistake.

I tried directly captureDesktopScreenshot but give me the error.

I searching a solution to save a large amount of screenshot in my hard drive, to prevent to save all in firefox and have slow firefox.

I had read that kantu removes characters that are not allowed in the file name but perhaps for export this is not applied.

You expect “:” to be stored as filename?

1 Like

With captureScreenshot all not allowed characters will be replaced in automatically.

I thought the same was true for the captureDesktopScreenshot command.

In my macro I used this to remove all not allowed character

{
“Command”: “storeEval”,
“Target”: “str = “${Screen}”; str= str.replace(/([^a-z0-9]+)/gi, ‘_’); str”,
“Value”: “Screen2”
},

Today i retry this command It is possible that I did something wrong.

Hi @commensal and @Plankton

The problem was solved was an illegal character inside the “time” variable “:” as you suggested.

I removed “:” from variable and now the macro works fine and saves the screenshots in the hard drive.

Thank you all for the advice.

1 Like