How to enable/allow clipboard permission popups in automated tests with Selenium web driver and JavaScript?
It works as expected when setting is set to 0 and 2 but not when setting is set to 1
setProperty(testOptions, 'desiredCapabilities/goog:chromeOptions/prefs/profile.content_settings.exceptions.clipboard', { '*':
{ setting: 0 }
});
setProperty(testOptions, 'desiredCapabilities/goog:chromeOptions/prefs/profile.content_settings.exceptions.clipboard', { '*':
{ setting: 1 }
});
setProperty(testOptions, 'desiredCapabilities/goog:chromeOptions/prefs/profile.content_settings.exceptions.clipboard', { '*':
{ setting: 2 }
});
Chrome has a special endpoint for this, so Selenium implements a separate method. In JS you can do:
await driver.setPermission('clipboard-read', 'granted')
await driver.setPermission('clipboard-write', 'granted')
options are: 'prompt', 'granted', and 'denied'
Example in our test code:
https://github.com/SeleniumHQ/selenium/blob/selenium-4.10.0/javascript/node/selenium-webdriver/test/chrome/permission_test.js#L37
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With