Pala Bhaskar Pala Bhaskar - 10 months ago 27
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;");


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