简体   繁体   English

使用JavascriptExecutor在Selenium中生成JavaScript警报

[英]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. 我想在警报以及消息中警报变量select book的值。

The single quotes are closed incorrectly 单引号关闭不正确

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

Hope this helps you... 希望这对您有帮助...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 JavascriptExecutor 的 Selenium Datepicker - Selenium Datepicker using JavascriptExecutor 使用Selenium GhostDriver中的JavascriptExecutor处理警报/确认 - Handling Alert/Confirm with JavascriptExecutor in Selenium GhostDriver 有没有办法使用 Selenium JavascriptExecutor 从 Java 中的 JavaScript 返回对象? - Is there a way to return an Object from JavaScript in Java using Selenium JavascriptExecutor? 使用Selenium中的JavascriptExecutor类捕获控制台错误 - Capture console error using JavascriptExecutor class in selenium 如何不使用javascriptExecutor在Selenium Webdriver中突出显示Webelement - How to highlight webelement in selenium webdriver not using javascriptExecutor 使用JavascriptExecutor selenium创建一个链接为背景的图像 - create an image with link as background using JavascriptExecutor selenium 使用javascriptexecutor更改selenium中的css背景值 - Using javascriptexecutor to change the css background value in selenium 如何在 Java selenium 中使用 JavascriptExecutor 获得 Javascript 的响应或如何提取<script> tag text? - How do I get response of Javascript using JavascriptExecutor in Java selenium or how to extract <script> tag text? 为什么此Javascript在浏览器控制台中有效,但在Selenium的JavascriptExecutor中却无效? - Why does this Javascript work in the browser console but not in Selenium's JavascriptExecutor? Selenium 中的 JavaScriptExecutor 是什么? - What is JavaScriptExecutor in Selenium?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM