ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
options.addArguments("disable-extensions");
prefs.put("credentials_enable_service", false);
prefs.put("password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
options.addArguments("chrome.switches","--disable-extensions");
options.addArguments("--test-type");
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, options);
cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
System.setProperty("webdriver.chrome.driver",*path of chromedriver.exe*);
wb = new ChromeDriver(cap);
Map<String, Object> prefs = new HashMap<String, Object>();
//To Turns off multiple download warning
prefs.put("profile.default_content_settings.popups", 0);
prefs.put( "profile.content_settings.pattern_pairs.*.multiple-automatic-downloads", 1 );
//Turns off download prompt
prefs.put("download.prompt_for_download", false);
prefs.put("credentials_enable_service", false);
//To Stop Save password propmts
prefs.put("password_manager_enabled", false);
ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
//To Disable any browser notifications
options.addArguments("--disable-notifications");
//To disable yellow strip info bar which prompts info messages
options.addArguments("disable-infobars");
options.setExperimentalOption("prefs", prefs);
System.setProperty("webdriver.chrome.driver", "Chromedriver path");
options.addArguments("--test-type");
driver = new ChromeDriver(options);
Log.info("Chrome browser started");
ChromeOptions cOptions = new ChromeOptions();
cOptions.addArguments("test-type");
cOptions.addArguments("start-maximized");
cOptions.addArguments("--js-flags=--expose-gc");
cOptions.addArguments("--enable-precise-memory-info");
cOptions.addArguments("--disable-popup-blocking");
cOptions.addArguments("--disable-default-apps");
_driver = new ChromeDriver(cOptions);
Thank you
Just in case someone sees that post , I added :
cOptions.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));
And it caused the driver to crash when calling:
driver().manage().window().maximize();
So I had to remove it. Anyway , Adding :
options.addArguments("disable-infobars");
solved the original issue. Thank you all for your help.
ChromeOptions options = new ChromeOptions();
options.AddUserProfilePreference("credentials_enable_service", false);
options.AddUserProfilePreference("password_manager_enabled", false);
ChromeDriver driver = new ChromeDriver(options);