有一些瀏覽器原生彈出窗口。我想通過Selinium關閉這些。通過硒驅動程序關閉瀏覽器的存儲權限
例如,當應用程序試圖訪問您的本地存儲並且會要求您的許可時。
這樣的彈出窗口阻止硒流。
Click here to view screen shot of the popup
有一些瀏覽器原生彈出窗口。我想通過Selinium關閉這些。通過硒驅動程序關閉瀏覽器的存儲權限
例如,當應用程序試圖訪問您的本地存儲並且會要求您的許可時。
這樣的彈出窗口阻止硒流。
Click here to view screen shot of the popup
使用的代碼片段:
Alert alert = driver.switchTo().alert();
alert.accept();
不適用於我。它會引發錯誤:「發生異常: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可以請你張貼彈出的屏幕截圖 –