Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

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;

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": ""