Setting up Chromeoptions and setExperimentalOption code

0 votes

I am unable to understand the meaning of following lines of code for setting up Chrome options in selenium code. Plz help

ChromeOptions options = new ChromeOptions();

Map<String, Object> prefs = new HashMap<String, Object>();

prefs.put("credentials_enable_service", false);

prefs.put("profile.password_manager_enabled", false);

prefs.put("profile.default_content_setting_values.notifications", 2);

options.setExperimentalOption("prefs", prefs);
Jul 23, 2018 in Selenium by Martin
• 4,210 points
851 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Here are the complete details:

ChromeOptions options = new ChromeOptions();

This creates an object by the name options of ChromeOptions Class.

Map<String, Object> prefs = new HashMap<String, Object>();

Here you have create a new Map object by the name prefs where the Key and Value fields accepts String and Object type of data and casted it to HashMap.


prefs.put("credentials_enable_service", false);

prefs.put("profile.password_manager_enabled", false);

prefs.put("profile.default_content_setting_values.notifications", 2);

In these three lines you have configured the pref-names within the prefs object.

options.setExperimentalOption("prefs", prefs);

Finally in this line you are using the setExperimentalOption method to set these experimental options (ChromeDriver options not yet exposed through the ChromeOptions API) within the optionsobject.

Now you can use this options object of ChromeOptions Class to initialize the WebDriver and Web Client as follows :

WebDriver driver = new ChromeDriver(options);

answered Jul 23, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

Setting browser width and height in Selenium Web Driver

For me, the only thing that worked ...READ MORE

answered Jul 19, 2018 in Selenium by Meci Matt
• 9,400 points
46 views
0 votes
1 answer

Pass driver ChromeOptions and DesiredCapabilities?

You can add ChromeOptions to DesiredCapabilities then create the driver with ...READ MORE

answered Aug 23, 2018 in Selenium by Meci Matt
• 9,400 points
435 views
0 votes
1 answer

How to handle IE protected mode zone and zoom level setting in selenium C#

For changing the zoom level you can ...READ MORE

answered Feb 13 in Selenium by Priyaj
• 56,120 points
204 views
0 votes
0 answers

How to write a code for combo box and how can i select a country from country dropdown?

Hi, I want to select a country from ...READ MORE

Mar 14 in Selenium by ch Praveen
340 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
58 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
423 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
44 views
0 votes
1 answer

How to create Date Object and Compare Dates?

You can convert pd to date (or ...READ MORE

answered May 4, 2018 in Selenium by Samarpit
• 5,130 points
19 views
0 votes
1 answer

NoSuchElementException exception with headless chrome and selenium

As you are seeing NoSuchElementException you can consider using ...READ MORE

answered May 7, 2018 in Selenium by Samarpit
• 5,130 points
1,399 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.