Converting JavaScript code from storeEval to executeScript_Sandbox in Selenium IDE using Kantu Ui.Vision

Looking for assistance with converting two snippets of Javascript code to extract date and time in a specific format, transitioning from storeEval to executeScript_Sandbox for use in Selenium Ide Kantu Ui.Vision.

Due to recent updates, storeEval is now deprecated and the new command executeScript_Sandbox must be utilized.

For more information, please refer to:

I require the conversion of these 2 codes from storeEval to executeScript_Sandbox compatible with the latest version of Selenium Ide Kantu Ui.Vision.

The initial code utilizing storeEval (deprecated) is as follows:

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

The second code using storeEval (deprecated) is provided below:

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;

Answer №1

When using the executeScript_Sandbox command, it is crucial to include a return statement for it to work effectively. The code has now been updated to be compatible with the new executeScript_Sandbox command for both selenium and Kantu.

The old storeEval function is no longer supported and should not be used as it is incompatible.

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to perform a legitimate POST request using AJAX XMLHttpRequest, rather than the traditional var=val URL type post?

Apologies for the unclear question, but here is my query... I recently began using Ajax and encountered an issue with sending XMLHttpRequest in the background. I am facing problems with certain html special characters in the form data, especially the & ...

How to apply props conditionally in VueJS?

I have a component called blogPost (Component A) that is imported in another component named B. When a button in Component B is clicked, Component A opens in a modal. There are two different use cases for this scenario. 1. One case requires passing 2 prop ...

Embed API allows users to showcase a variety of charts all on one page

I am trying to incorporate two google analytics timeline charts using the embed API on a single page. However, I am facing an issue where only one chart is appearing. The first chart should display bounce rate data and the second chart should display sessi ...

div maintain aspect ratio while scaling

My current layout is structured like this: HTML <div id="container"> <div id="zoomBox"> <div class="box"></div> <div class="box"></div> <div class= ...

Empty results received from MongoDB queries executed within an asynchronous loop

I'm encountering an issue where I have a list of IDs that I need to query Mongo with in a for loop, but it always returns an empty []. Initially, the queries were returning promises, so I switched from using forEach to a standard for loop as shown her ...

AngularJS restricts inputs to be read-only

I'm facing an issue with readonly inputs in AngularJS. I have a select element that changes the values of readonly inputs through a script. However, when I attempt to display these values using ng-model in a table as {{ng-model}}, they don't appe ...

After entering text manually, the textarea.append() function ceases to function properly

I've encountered a puzzling issue with a tiny fiddle I created: https://jsfiddle.net/wn7aLf3o/4/ The scenario is that clicking on 'append' should add an "X" to the textarea. It functions perfectly until I manually input some text in the te ...

I am seeking assistance with locating a button using Selenium Firefox Webdriver and require guidance on the code necessary to click the

Seeking assistance with Selenium to click on the Income Statement button located at . Can anyone identify the button name and review the code for accuracy in implementing it? Grateful for any guidance. Thank you! url = 'http://www.tradingview.com/scre ...

The module 'NgAutoCompleteModule' was declared unexpectedly by the 'AppModule'. To fix this issue, make sure to add a @Pipe/@Directive/@Component annotation

Currently, I am attempting to integrate an autocomplete feature into my Angular 2/4+ project. Despite trying various libraries, none of them seem to be working correctly. Each one presents me with a similar error message: Unexpected module 'NgAutoCom ...

Executing multiple commands using Node.js TCP communication

I have established a connection to a serial device via the internet using an ethernet to serial device. The communication is facilitated through a small node.js application. The provided code retrieves the necessary information: var net = require('ne ...

What is the best way to insert HTML elements in front of other HTML elements using a form and jQuery?

I am looking to insert new HTML elements before existing ones using a form and jQuery: Here is the initial HTML Code: <div class="main-content"> <h2 class="main-content-header">Projekte</h2> <div class="project-content"> ...

Using Selenium with Python, ensure that after clicking a button, the program waits for all newly loaded elements, regardless of their attributes, to fully load

Is there a way to wait for all newly appearing elements on the screen to fully load after clicking a particular button? While I understand that the presence_of_elements_located function can be used to wait for specific elements, how can I ensure that all ...

Integrating dual Google Maps onto a single HTML page

I'm facing an issue with implementing two Google maps on a single page where the second map seems to be malfunctioning. Below is the code I am currently using: <style> #map-london { width: 500px; height: 400px; } #map-belgium { wi ...

Issue with Material UI select component not displaying the label text

I've been struggling with Material UI's "Select" for quite some time now - spent about 10 hours trying to make it work the way I want. Any help would be greatly appreciated. This question is connected to a previous one: Select MenuItem doesn' ...

Full replacement of a cell within an HTML table

I have a scenario like the following: <table id="myTable"> <tr> <td class="1">cell 1</td> <td class="2">cell 2</td> </tr> <tr> <td class="3">cell 3</td> &l ...

What can be done to ensure that two separate react-native Picker components do not interfere with each other's

Encountering an issue with two Pickers in a react-native View. Whenever I select a value in one Picker, it causes the other Picker to revert back to its initial item in the list. It seems like the onValueChange function is being triggered for both Pickers ...

obtaining Json format from an array: a comprehensive guide

Hey there, I am looking to convert my array into JSON format. Currently, my array structure looks like this: Array[0] abc: Array[1] 0: "English" length: 1 abc1: Array[2] 0: "English" 1: "Urdu" length: 2 Here is the structure that I want in JSON using Jav ...

Adjust the constant state in one component using another component

I created a React application with a simple menu that switches state when clicked to open and close it. The functionality works as expected with the menu button located within the same component. However, I now face a challenge in trying to open the menu f ...

How to invoke a function from a different ng-app in AngularJS

I have 2 ng-app block on the same page. One is for listing items and the other one is for inserting them. I am trying to call the listing function after I finish inserting, but so far I haven't been successful in doing so. I have researched how to cal ...

What are some ways to enhance the speed of my canvas animations?

My code generates imagedata and places it in a canvas. However, when I expand the window size, the rendering slows down significantly. Is there a way to optimize this for smooth operation in fullscreen mode, even though it might seem naive? What would be ...