How to pass chromeOptions through config files

342 views
Skip to first unread message

Nick Prescott

unread,
Oct 22, 2015, 11:56:46 AM10/22/15
to WTFramework
It looks like the latest Chrome update is blocking popups and I am trying to disable this functionality. However, I haven't been able to figure out how to do this using the WTF config files.
Does anyone have experience setting ChromeOptions in the config yaml files?

alternatively, if I need to manually create a driver instance with the chromeOptions set like the following:
chrome_options = Options()
chrome_options.add_argument('--disable-popup-blocking')
self.driver = webdriver.Chrome(chrome_options=chrome_options)

How can I 'register' this driver so that subsequent calls to WTF_WEBDRIVER_MANAGER.get_driver() will use my driver instance?

Any help would be appreciated.

Nick Prescott

unread,
Dec 14, 2015, 4:04:49 PM12/14/15
to WTFramework
I'm still having problems setting chromeOptions using the config files, and it looks like the yaml may not be correctly parsed for nested dictionaries.

example: 
The following code will correctly initialize a browser instance with a different default download directory using chromeOptions:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('prefs', {'download.default_directory': '<directory_location>'})
self.driver = webdriver.Chrome(chrome_options=chrome_options)

The wtframework debug code shows that the browser has the following dictionary defining it:
{"desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true, "chromeOptions": {"prefs": {"download.default_directory": "<directory_location>"}, "extensions": [], "args": []}}}

However, if I try to create the same configuration in my config file like so:
desired_capabilities:
    platform: WINDOWS
    name: foo_bar
    chromeOptions: 
      prefs: 
        download.default_directory: <directory_location>

Then the debug output showing the dictionary structure is not the same:
{"desiredCapabilities": {"name": "foo_bar", "chromeOptions.prefs.download.default_directory": "<directory_location>", "javascriptEnabled": true, "platform": "WINDOWS", "browserName": "chrome", "version": ""}}

Just wondering if anyone else has hit this problem or ideally found the correct syntax or a workaround?

Thanks,
Nick

Reply all
Reply to author
Forward
0 new messages