AAA
AAA

Reputation: 448

How to set Google chrome preference using Selenium web driver?

I tried setting chrome pref usinf ChromeOption class using the following code snippet

Map<String, String> prefs = new Hashtable<String, String>();
prefs.put("download.prompt_for_download", "true");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("prefs", prefs);
//capabilities.setCapability("download.prompt_for_download", true);
driver = new EventFiringWebDriver(new ChromeDriver(capabilities));

But no luck I am using latest driver version 2.35. I wanted to set prompt for download.

Upvotes: 0

Views: 5321

Answers (1)

Arran
Arran

Reputation: 25076

Sometimes there can be a small issue with string version of boolean's and the actual boolean (i.e "true" vs true)

So I'd give this a test (untested):

Map<String, Boolean> prefs = new Hashtable<String, Boolean>();
prefs.put("download.prompt_for_download", true);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("prefs", prefs);
driver = new EventFiringWebDriver(new ChromeDriver(capabilities));

Upvotes: 1

Related Questions