driver.switchTo().alert().accept();
无法使用我的系统。所以,我使用了以下代码:
driver.findElement(By.name("submit")).click();
Thread.sleep(1000);
((JavascriptExecutor)driver).executeScript("window.close = function(msg){return true;}");
Object txt = ((JavascriptExecutor)driver).executeScript("return window.alert.myAlertText;");
//*** The following statement not getting executed***
System.out.println("Hello");
System.out.println(txt.toString());
此警报消息关闭后。但是,System.out.println
未打印所需的消息。