Skip to content

Instantly share code, notes, and snippets.

@gauntface
Created March 6, 2017 22:21
Show Gist options
  • Select an option

  • Save gauntface/bda55707a30b4e9cb63a5894dd57caf3 to your computer and use it in GitHub Desktop.

Select an option

Save gauntface/bda55707a30b4e9cb63a5894dd57caf3 to your computer and use it in GitHub Desktop.
const webdriverChrome = require('selenium-webdriver/chrome');
const notificationPermission = {};
notificationPermission[testServerAddress + ',*'] = {
setting: 1,
};
const chromePreferences = {
profile: {
content_settings: {
exceptions: {
notifications: notificationPermission,
},
},
},
};
// Write to a file
const tempPreferenceDir = path.join(__dirname, 'tmp', 'chrome-prefs');
mkdirp.sync(tempPreferenceDir + '/Default');
const preferenceFilePath = path.join(tempPreferenceDir, 'Preferences');
fs.writeFileSync(
preferenceFilePath,
JSON.stringify(chromePreferences));
const options = new webdriverChrome.Options();
options.addArguments('user-data-dir=' + tempPreferenceDir);
const builder = new webdriver
.Builder()
.forBrowser(‘chrome’)
.setChromeOptions(options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment