0

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;
Guy
  • 46,488
  • 10
  • 44
  • 88
pachiro
  • 59
  • 6
  • According to the docs, the Sandbox version works exactly the same way as before it's just a difference of where it is run... so what's the issue? Did you run your code using Sandbox? What was the result? Where is the error? – JeffC Oct 03 '19 at 20:10
  • I posted the solution, you can read it, if you do not know selenium and kantu can not solve this question. – pachiro Oct 04 '19 at 13:58

1 Answers1

0

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": ""
    }
  ]
}
pachiro
  • 59
  • 6