Selenium IDE's float calculation in javascript results in a value of 1 instead of the expected 1.99

I am trying to perform a JavaScript evaluation in Selenium IDE that involves multiplying 3 decimal values.

javascript{parseFloat(storedVars['val1'])*parseFloat(storedVars['val2'])*parseFloat(storedVars['val3'])}

However, when I run the code, it only returns a value of 1.

Executing: |store | javascript{parseFloat(storedVars['val1'])*parseFloat(storedVars['val2'])*parseFloat(storedVars['val3'])} | couponOdds |

[info] Executing: |echo | Total odds value: ${val1} *${val2} *${val3} = ${couponOdds} | | [info] echo: Total odds value: 1.02 * 1.50 * 1.30 = 1

What can be done to ensure that the calculation works correctly?

Answer №1

Upon analyzing the given output, it appears that using a comma , instead of a period . as a decimal point may be causing the issue. This discrepancy is common in different regions. The parseFloat function recognizes only the period . as a valid decimal point.

One possible solution could be:

javascript{parseFloat(storedVars['val1'].replace(/,/g, "."))*parseFloat(storedVars['val2'].replace(/,/g, "."))*parseFloat(storedVars['val3'].replace(/,/g, "."))}

However, creating a separate function like localeParseFloat would be more efficient than replacing commas every time.

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

Populate a 2D array in JavaScript/NodeJS "line by line"

Hey there! I could really use some help with JavaScript/NodeJS arrays. Here is the code I'm working with: let arr = new Array(); arr = { "Username" : var1, "Console" : var2, "Pseudo" : var3, } console.log(arr); The variables var1, var2, ...

Receive a notification when the div element stops scrolling

I am attempting to replicate Android's expandable toolbar within an Angular component. My HTML code appears as follows: <div (scroll)="someScroll($event)"> <div class="toolbar"></div> <div class="body"></div> </d ...

Python Selenium is having trouble locating an element by its XPath inside the #shadow-root (open) when using both Python and Selenium

While exploring the contents of this site: I attempted to click on the button labeled as: "Alle bestätigen" using the script provided below: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui imp ...

Utilizing Capybara, Selenium, and Jupyter Notebook to populate a code cell

Trying to use Capybara to input text into a Jupyter Notebook cell has been a challenge. Clicking the element and using 'send_keys' does not seem to do the trick, even though the cursor is in the correct location: find(".input").click.send_keys("h ...

What is the best way to update the current route in Angular 2 programmatically?

In my Angular 2 application, I am facing an issue with the navigation flow between the home component and the nav panel component. When a user clicks on the logout button in the nav panel, the current URL is correctly shown as "/login" in the console log. ...

MUI Input component does not support the use of the oninput attribute

My MUI Input component is defined like this, but the oninput attribute doesn't seem to work in MUI: <Input variant="standard" size="small" type="number" inputProps={{ min: '0', o ...

Internet Explorer 9 does not display content until the ajax/json function has finished executing

I have encountered an issue with my code regarding updating a div element. The first innerHTML call seems to be ineffective and does not render in the browser. However, the second innerHTML call works as expected by appending "Complete" once the ajax call ...

How come I am receiving {"readyState":1} in the DOM instead of JSON data in AngularJS?

Currently, I am facing an issue where instead of the JSON data (which consists of only 49 items) showing up on the DOM, I am getting {"readyState":1}. I believe this is just a test to ensure that my code is functioning correctly. Although I have identifie ...

Troubleshooting the Problem of Adding Class with jQuery Click

Good day, I've been struggling with this issue all day. Almost got it working but not quite there yet. The problem is that I need the corresponding paragraph (#p-1 etc) to remain highlighted once the thumbnail is clicked. I have customized a plugin fo ...

The AJAX response is shown just a single time

My code is designed to send an ajax request when a form is submitted, specifically a search module. It works perfectly the first time the form is submitted, highlighting the table when data is returned. However, I am only able to see the effect once, as th ...

Using Node.js and jQuery to retrieve a PDF from a server and showcase it on the frontend

I'm currently facing a roadblock. My goal is to retrieve all files (filenames) from a static folder along with its subfolders and display them on the front-end. Once a user clicks on one of the filenames, which are mostly PDFs, I want the server to r ...

Display all items that are currently enabled in the list

Here is a breakdown of what my code accomplishes: (1.) Launch Chrome browser and navigate to footlocker.ca (2.) Click on the Men's category (3.) Choose a random product from a list of 60 (4.) Display the product name and price (5.) Show all avail ...

Ways to create collapsible navigation bars in your website

As someone exploring client-side development, I may be misusing the term "collapsible" in my title. What I aim to accomplish in my web application is allowing users to collapse header bars into small chevrons and expand them back when necessary. I am on t ...

The id property of undefined cannot be accessed in the discord.js library

I am currently developing a Discord bot that assigns a role temporarily whenever a specific word is mentioned. Despite thoroughly checking my code, I continue to encounter the following error: message.member.roles.add(role555.id); ...

Discover the ins and outs of utilizing the Google+ Hangout API specifically for chatting purposes

I am currently working on a webpage and I want to include a hangout button that will allow users to connect with me and start chatting automatically when clicked. Here is the code I have so far: <script src="https://apis.google.com/js/platform.js" asy ...

Two-way data bindings trigger the digest() function to iterate 10 times

I'm facing issues with angular binding and my experience level in this area is limited. I will be posting all related questions here. I have a piece of angularjs code that is triggering 10 digest() cycle reached errors. After researching similar posts ...

What is the best way to showcase a collapsible tree using AngularJS and Bootstrap?

I'm currently working on a web application that requires the display of a tree structure using lists. Here is the basic outline: * Node 1 * Node 1.1 * Node 1.1.1 * Node 1.1.1.1 * Node 1.1.2 * Node 1.2 http://jsfid ...

Building an accordion collapse feature in HTML using CSS and JavaScript

I've been working on creating an accordion interface, but I'm facing an issue where only the first collapsible button works properly. The rest of the buttons are not functioning and don't even appear on the page. When I remove the CSS styli ...

Using Python Javascript framework in conjunction with Cherrypy and Mako for dynamic web development

Recently, I started delving into the world of Python and Python web applications. Please excuse my limited knowledge as I am still learning. Currently, I am developing a web application in Python with CherryPy, Mako, and HTML. Now, I have reached the poin ...

Error: The operation 'join' cannot be performed on an undefined value within Fast2sms

I am encountering issues while attempting to send SMS using fast2sms in Node.js. The error message reads as follows: TypeError: Cannot read property 'join' of undefined at Object.sendMessage (C:\Users\user\Desktop\node_module ...