javascriptseleniumsandboxexecute-script

Conversion javascript code from storeEval to executeScript_Sandbox (Selenium Ide Kantu Ui.Vision)


I need a conversion of two javascript code to obtain date and time in prefered format from storeEval To executeScript_Sandbox to use in Selenium Ide Kantu Ui.Vision

From some update storeEval is deprecated and now need to use the new command executeScript_Sandbox

Here some info: https://ui.vision/docs/selenium-ide/executescript

I need conversion of 2 codes from storeEval To executeScript_Sandbox compatible with new Selenium Ide Kantu Ui.Vision.

My first code for storeEval (deprecated)

var d = new Date();
var m = ((d.getMonth() + 1 ) < 10) ? "0" + (d.getMonth() + 1) : (d.getMonth() + 1);
var day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
day + "-" + m + "-" + d.getFullYear();

My second code for storeEval (deprecated)

let d = new Date();
let h = d.getHours();
h = h < 10 ? "0" + h : h;
let m = d.getMinutes();
m = m < 10 ? "0" + m : m;
let s = d.getSeconds();
s = s < 10 ? "0" + s : s;
h + "-" + m + "-" + s;

Solution

  • This is the solution executeScript_Sandbox command require return otherwise do not works, now the code is compatible with the new executeScript_Sandbox command (selenium and Kantu).

    Old storeEval is deprecaded and not compatible.

    {
      "Name": "test-date",
      "CreationDate": "2019-10-4",
      "Commands": [
        {
          "Command": "executeScript_Sandbox",
          "Target": "var d = new Date();var m = ((d.getMonth()+1)<10) ? \"0\" + (d.getMonth()+1):(d.getMonth()+1);var day=d.getDate()<10 ? \"0\" + d.getDate():d.getDate();return day + \"-\" + m + \"-\" + d.getFullYear();",
          "Value": "text1"
        },
        {
          "Command": "executeScript_Sandbox",
          "Target": "let d = new Date(); let h = d.getHours(); h = h < 10 ? \"0\" + h : h; let m = d.getMinutes(); m = m < 10 ? \"0\" + m : m; let s = d.getSeconds(); s = s < 10 ? \"0\" + s : s; return h + \"-\" + m + \"-\" + s;",
          "Value": "text2"
        },
        {
          "Command": "echo",
          "Target": "${text1}",
          "Value": ""
        },
        {
          "Command": "echo",
          "Target": "${text2}",
          "Value": ""
        }
      ]
    }