selenium.JavascriptExecutor执行文本输入如何换行
简单的一段代码:import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.Alert;
import java.awt.*;
import javax.swing.*;
import command.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
public class test {
public static void main(String[] args) throws Exception {
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.baidu.com");
String kk = "alert(\"123 456\");";
((JavascriptExecutor)driver).executeScript(kk);
}
}
上面这段代码实现弹出一个alert框,显示123 456
现在我想把123跟456换行显示,就是
123
456
我用String kk = "alert(\"123 \n456\");";结果提示javascript error,一直无法执行,这个哪里有问题,谢谢!
页:
[1]