Selenium JS : can't get rid of exception unexpected alert open: {Alert text : xxx}
I have a page in which an alert box may appear randomly if I click on a button. I auto click on this button every 5 seconds. I want to get rid/ignore all possible alerts but it the exception unexpected alert open: {Alert text : xxx} won't disappear despite I tried this :
Solution (1) that I tried
// Add --disable-notifications to chrome opti开发者_运维技巧ons
let options = new chrome.Options();
options.addArguments("--disable-notifications")
const driver = new
webdriver.Builder().forBrowser("chrome").setChromeOptions(options).build();
Solution (2) that I tried :
// set the driver capabilities to accept silently all dialogs
// I double-checked the key/values strings of the capabilities
const capabilities = await driver.getCapabilities()
await capabilities.set('unhandledPromptBehavior', 'accept')
Any idea ?
精彩评论