Pala Bhaskar Pala Bhaskar - 1 year ago 57
Javascript Question

error occured while executing the javascript code in java

I want to execute javascript code in java. So I Wrote the code as shown in below. But during execution it fails at middle line. saying error as 'missing ; before statement '.

JavascriptExecutor js = (JavascriptExecutor)driver;

String g=(String) js.executeScript("var r = confirm('r u ready');"+"if(r==true) { Var b='ok'; } return b;");


Answer Source
"(function() {var r,b; r = confirm('r u ready'); if(r == true) { b='ok'; } return b;})()"