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

Conceal flexbox item depending on neighboring element dimensions or content

I've encountered an issue while using a flexbox to display two elements side by side. The left element contains text, while the right one holds a number. When the value in the right element has at least 7 digits ( > 999,999 or < -999,999), I ne ...

Removing an individual HTML element within a form using JavaScript Fetch() in the presence of multiple components

The Situation Having a form that includes image components generated from a MySQL database with PHP, I've implemented javascript fetch() functionality on different pages of the website to enhance user experience. However, in cases where the functiona ...

Differences between Selenium IDE and Selenium Web Driver

When it comes to automating web projects, which option is best? Selenium IDE Selenium WebDriver I am looking to automate a web application and this decision is really causing me confusion. ...

Checking to see if the prop 'isChecked' has been modified

I'm currently facing a challenge with testing whether a class's prop value changes after clicking the switcher. Below is the component class I am working with: import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core&a ...

What is the best way to link a newly created contact to the current user in Mongoose?

I'm faced with the challenge of creating a contact that is specifically added to the current user's contact array. Currently, my controller only creates a generic contact and doesn't cater to the individual user. Controller: function cont ...

What method is most effective for combining two JSON files in Angular?

My data includes a json file with a product list that looks like this: [{"id":76, "name":"A", "description":"abc", "price":199, "imageUrl":"image.jpg", "productCategory":[{ "categoryId":5, "category":null },{ "categoryId":6, " ...

Having trouble creating an alias system in discord.js and encountering errors

While developing an alias system for my Discord bot, I encountered a situation where I wanted to display the message: "if the user entered the wrong command name or alias then return: invalid command/alias". However, when implementing this logic, ...

Simplified JavaScript Object Structure

A JSON array that is flat in structure looks like this: var flatObject = [ { id : "1", parentId : "0", name : "object 1" }, { id : "2", parentId : "1", name : "object 2" }, { id : "3", parentId : "2", name : "object 3" }, { id : "4", pare ...

Are there any pre-existing pop-up methods available for AngularJS?

Is there a way to create a simple pop-up window with static text and just one "Ok" button? In Java/Swing, it's possible to achieve this with just one line of code using pre-defined classes. However, when it comes to Angular pop-ups, it seems like the ...

What is the best way to clear an arrayList when an error occurs in the ajax response?

Within my code, I have initialized an empty arrayList as var selection11Data = [];. Data is retrieved from an AJAX call as shown below: var selectionId=trData.selectionId; console.log("here"); $.ajax({ url : A_PAGE_ ...

Error in React Router when using TypeScript

Encountering errors while trying to set up router with React and TypeScript. https://i.sstatic.net/muSZU.png I have already attempted to install npm install @types/history However, the issue persists. Your assistance would be greatly appreciated. Thank y ...

Obtaining Data from CRM 2011 with the Power of jQuery and JavaScript

Currently, I am facing an issue while attempting to retrieve data from CRM 2011 using jQuery. Despite my efforts, I am unable to successfully fetch the desired data. Below is the code that I have been working on: function GetConfigurations() { var oDataP ...

An error was encountered involving an unexpected token < at the beginning of a JSON file while using express with firebase

After setting up an authentication system in express using firebase auth, I established an endpoint in my express server: app.post('/users/login', (req, res) => { console.log('logging in...'); firebase.auth().signInWithEmail ...

Facing an issue in React-Native where unable to navigate to the second screen

I hope you don't mind the length of my query, as this happens to be my debut here and I am really eager to unravel the mysteries surrounding my code conundrum. Your assistance in this matter would be greatly appreciated. Could someone please lend me ...

Error: SvelteKit server-side rendering encountered a TypeError when trying to fetch data. Unfortunately, Express is not providing a clear TypeScript stack trace

I've been monitoring the logs of the SvelteKit SSR server using adapter-node. After customizing the server.js to utilize Express instead of Polka, I noticed some errors occurring, particularly when the fetch() function attempts to retrieve data from ...

switchMap: Triggering multiple requests simultaneously (2)

Currently, I am utilizing Angular 2 RC-4 and facing an issue where a network request is being triggered twice whenever there is a change in the input box. This is what my code looks like: component.ts this.term = new Control(); this.suggestions = this. ...

Posting data using an Ajax form submission without the need for page

After numerous attempts, I am still facing an issue where clicking the Submit button causes the page to refresh. What changes should I make to resolve this problem? <script> $('#submit').on('submit', function(event) { event.pre ...

A step-by-step guide to effortlessly opening and managing nearly 50 tabs in Chrome with ChromeDriver and Selenium using Python

I'm currently working on a project that involves scraping data from multiple webpages using Selenium and Python. I have successfully implemented the code for extracting information from a single tab. However, I now face the challenge of opening 50 tab ...

Displaying geoJSON data from a variable instead of a file is a feature implemented by

Let's say I have a geoJSON data stored in a variable or parsed as an object: // GeoJSON stored as an object var segment = segment; // GeoJSON saved as a JSON string var json = JSON.stringify(segment); Now, the challenge is to display this geoJSON o ...

Unique ActionBar design for my NativeScript-Vue application

I'm currently working on customizing the ActionBar for my nativescript-vue app. I have implemented FlexBoxLayout within the ActionBar, but I am facing an issue where the icon and title of the bar are not aligning to the left as intended; instead, they ...