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,320 points
12,246 views

1 answer to this question.

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,910 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,460 points
1,180 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,460 points
2,616 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, 2019 in Selenium by Priyaj
• 58,020 points
4,459 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,766 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,185 views
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,910 points
7,259 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,897 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,910 points
1,320 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,910 points
8,290 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP