// 使用driver.switchTo().alert()方法获取alert对象 Alert alert = driver.switchTo().alert(); // 使用alert对象的accept方法,单击alert框上的确定按钮,关闭alert框 alert.accept();