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.
Using variable in middle of the query
_set($output, 123);
$dateformat = new java.text.SimpleDateFormat("yyyyMMdd").format(new java.util.Date());
var $query = "select * from tablename_"+$dateformat+" where id = " + $output;
var $rs = $mydb.select($query);
Please let me know what's wrong in query.
I want the query to be "select from tablename_20100625 where id = 123;
When I run script it give me "JSERROR SyntaxError: missing ] after element list"
$dateformat = new java.text.SimpleDateFormat("yyyyMMdd").format(new java.util.Date());
var $query = "select * from tablename_"+$dateformat+" where id = " + $output;
var $rs = $mydb.select($query);
Please let me know what's wrong in query.
I want the query to be "select from tablename_20100625 where id = 123;
When I run script it give me "JSERROR SyntaxError: missing ] after element list"
This discussion has been closed.
Comments
I think your query is correct. You can check it by alerting it.
var $query = "select * from tablename_"+$dateformat+" where id = " + $output;
_alert($query)
Your error is similar to the one reported in another forum post.
http://sahi.co.in/forums/viewtopic.php?pid=5454
I suspect that it may be related to the data being fetched. You can try just selecting a few columns and checking which column causes the problem.
Regards,
Narayan
Thanks, There was some problem in fetching the data and its working fine now.
I corrected it, but in View Logs it says "JSERROR SyntaxError: missing ] after element list" which is bit difficult to know the exact error.
Another issue:
_setValue(_textarea("text"), "hi how r u\nhi how r u");
while running with sahi, it inserts with two newline after the first line, can you please help me out.
While I run without sahi it works fine.
Thanks,
Prashanth NK
We are investigating the SyntaxError.
The _setValue seems to work fine on IE 8 and FF 3.6.4 (The lines come in 2 lines with out any space in between.)
What browser/OS (with versions) are you using?
Regards,
Narayan
I use Windows XP3 and Firefox 3.6.4.
_setValue(_textarea("text"), "hi how r u\nhi how r u");
Above set value has only one \n
While inserting into db it inserts as
hi how r u
hi how r u
Two new lines were created instead of one new line.
Thanks,
Prashanth NK
Is this a bug or is there a solution for this. Please let me know
This works fine in IE but in firefox 3.6.* there is a problem
Thanks,
Prashanth NK
I am on FF3.6.6 and Win7, and it works fine.
As a workaround, and if you are not concerned about key events, you could use
Regards,
Narayan
Thanks a lot. Its working fine with the given syntax.
Thanks,
Prashanth NK