我在Java中有一个String变量。 我想使用硒中的JavascriptExecutor类将该字符串变量传递给javascript变量
String eventNameFromExcel = "search results contact";
JavascriptExecutor jse = (JavascriptExecutor)driver;
List<?> al = (List<?>) jse.executeScript( "var source = [];"+
"var filterIndex=0;"+
"var eventString ="+eventNameFromExcel +";"+ //throws error unexpected identifier
"if(dataLayer[j][\"event\"] == eventString){"+
"filterIndex=j;"+
"break;}"+
"}");