1

Things tried

String selectBook="abc"; 
String script="alert('"+selectBook+"' book does not exist');"; 
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript(script);    

I want to alert the value of variable select book in alert along with the message.

2
  • print out "String script"... maybe you'll notice something off. Commented Jul 10, 2015 at 6:24
  • Printing script value gives: alert('abc' book does not exist'); Commented Jul 10, 2015 at 6:38

1 Answer 1

1

The single quotes are closed incorrectly

String script="alert('"+selectBook+" book does not exist');"; 

Hope this helps you...

Sign up to request clarification or add additional context in comments.

1 Comment

Hi @Grishma Did the above solution help you??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.