从 storeEval 到 executeScript_Sandbox 的转换 javascript 代码(Selenium Ide Kantu Ui.Vision)

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

我需要转换两个 javascript 代码以从 storeEval 获取首选格式的日期和时间到 executeScript_Sandbox 以在 Selenium Ide Kantu Ui.Vision

来自一些更新 storeEval 已被弃用,现在需要使用新命令 executeScript_Sandbox

这里有一些信息: https://ui.vision/docs/selenium-ide/executescript

我需要将 2 个代码从 storeEval 转换为 executeScript_Sandbox 兼容新的 Selenium Ide Kantu Ui.Vision.

我的第一个 storeEval 代码(已弃用)

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();

我的第二个 storeEval 代码(已弃用)

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;

这是解决方案 executeScript_Sandbox 命令要求 return 否则不起作用,现在代码与新的 executeScript_Sandbox 命令(selenium 和 Kantu)兼容。

旧的 storeEval 已弃用且不兼容。

{
  "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": ""
    }
  ]
}