18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
sahi + toLocaleString
Hi All,
Does Sahi support toLocaleString? Testing my code in the controller I get unexpected results, and when I run the compiled script I get an "illegal radix at 0." error.
Thanks,
Jason
Does Sahi support toLocaleString? Testing my code in the controller I get unexpected results, and when I run the compiled script I get an "illegal radix at 0." error.
Thanks,
Jason
Best Answer
-
Hi jasonb,
Yes Sahi does support toLocaleString which is a javascript function.
Please have a look at the following script that works for me with SahiV4.4.var d=new Date(); var n=d.toLocaleString(); _alert(n);
Please let me know your testscript and/or the screenshot of the problem you're facing. Also, what version of Sahi are you using?
Regards.
Answers
Version of sahi:
Version : V4.4
Build : 2013-04-29 (change log)
What I'm trying to do is take a string I've manipulated (stripped currency symbol and thousands separators) and turn it back into the original currency string. The reason I can't simply store two separate variables is that I add a random number to the manipluated string, and this value is then asserted at a later stage.
This is what's happening for me.
//Get current limit
$current_limit = _getText(_cell(xyz)); == USD 100,000.00
//Strip out the currency symbol and commas
$str = $current_limit.replace(/[a-z,\","]/gi, ""); == 100000.00
//Add amount to above to get new limit, and preserve the decimals
$new_limit = (+$str + 100.50).toFixed(2); == 100100.50
//Problem starts here
$x = Number($str).toLocaleString(); == 100,000
In my regional settings, a positive number shows as 123,456,789.00, so surely the end result should include decimals?
Bear in mind that js is very new for me, so I completely admit that I'm interpreting the toLocaleString function incorrectly, I just wanted to make sure that using it wasn't improper. Will wait for any advice on above before asking anything else.
jasonb