简体   繁体   中英

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.

The single quotes are closed incorrectly

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

Hope this helps you...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM