OS: OSX 10.11.4
Selenium Version: latest NodeJS selenium-webdriver/chrome
Browser: Chrome
I saw here:
https://github.com/seleniumhq/selenium/issues/1501
that notifications are in the feature request list, so I wanted to deactivate the notification feature in chrome using the chrome experimental options in NodeJS. Nevertheless it does show the notification. Perhaps this feature isn't supported atm.
does not show notifications
does show the notifications
I've tried the following:
var options = new chrome.Options();
options.addArguments("profile.default_content_setting_values.notifications", "2");
var driver = new webdriver.Builder().withCapabilities(options.toCapabilities()).build();
The following code works in Java.
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);
addArguments sets command line switches for the browser.
I believe you want to use setUserPreferences
var options = new chrome.Options();
options.setUserPreferences({'profile.default_content_setting_values.notifications': 2});
var driver = new webdriver.Builder().withCapabilities(options.toCapabilities()).build();
I have this configuration
but it is not working.
var options = new chrome.Options()
.setUserPreferences({'profile.default_content_settings.popups': '0'})
.setUserPreferences({'profile.default_content_setting_values.notifications': '2'})
.addExtensions('./myextension.crx');
var driver = new webdriver.Builder()
.withCapabilities(options.toCapabilities())
.build();

In my case I want to _allow_
Let me know if you know how to configure that.
I believe the idiom has changed to:
var caps = webdriver.Capabilities.chrome();
caps.set('dns-prefetch-disable', '0')
driver = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(caps)
.build();
Is that correct?
*try this works for me .*
var selenium = require('selenium-webdriver');
var capabilities = selenium.Capabilities.chrome();
capabilities.set('chromeOptions',{
'args': ['--headless', '--disable-gpu']
})
var builder = new selenium.Builder().forBrowser("chrome").withCapabilities(capabilities).build();
Most helpful comment
*try this works for me .*
var selenium = require('selenium-webdriver');
var capabilities = selenium.Capabilities.chrome();
capabilities.set('chromeOptions',{
'args': ['--headless', '--disable-gpu']
})
var builder = new selenium.Builder().forBrowser("chrome").withCapabilities(capabilities).build();