更新时间:2023-11-03 19:22:34
尝试一下:
if (driver instanceof JavascriptExecutor) {
System.out.println("In try");
((JavascriptExecutor)driver).executeScript("document.getElementById('comment').value=\'" + line1 + line2 + "\';");
} else {
throw new IllegalStateException("This driver does not support JavaScript!");
}
要将字符串元素传递给脚本字符串,您需要在单引号前放置\
.希望这会有所帮助.
To pass a string element to your script String, You need to put \
before the single quotes. Hope this helps.