通过硒驱动程序关闭浏览器的存储权限
答
使用的代码片段:
Alert alert = driver.switchTo().alert();
alert.accept();
+0
不适用于我。它会引发错误:“发生异常:org.openqa.selenium.NoAlertPresentException”。它不是JavaScript警报。弹出窗口来自浏览器地址栏,请求用户在设备上存储文件的权限。 – mahesh
答
你好,请使用Java Robot类,关闭该浏览器基于弹出窗口
Robot robot = new Robot();
// now try to press tab with robot (by doing this you can make focus of your control)
// then simply click with the help of robot
// for robot methods please check this link
https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html
希望这可以帮助你
mahes可以请你张贴弹出的屏幕截图 –