Grishma Oswal
Grishma Oswal

Reputation: 303

generating javascript alert in selenium using JavascriptExecutor

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.

Upvotes: 1

Views: 2153

Answers (1)

Vicky
Vicky

Reputation: 3021

The single quotes are closed incorrectly

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

Hope this helps you...

Upvotes: 1

Related Questions