Reputation: 13
My goal is to use Chrome as a service to display a fullscreen webpage on a screen. I'm tackling this challenge by creating a python script which uses Selenium to direct chrome to the correct page, and to format the site correctly. Due to the main requirement being a display it's important that the displayed webpage is unobstructed. There are two obstructions in my instance that can both be dealt with by using different excludeSwitches options:
To disable the automation bar:
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']);
To disable the 'Disable developer mode extensions' popup:
chrome_options.add_experimental_option("excludeSwitches", ['load-extension'])
However I've not found a way to implement both at the same time - I've tried:
chrome_options.add_experimental_option("prefs", {"excludeSwitches": ['enable-automation'], "excludeSwitches": ['load-extension']});
prefs = {"excludeSwitches": ['enable-automation, load-extension'], "excludeSwitches": ['load-extension', 'enable-automation']}
chrome_options.add_experimental_option("prefs", prefs);
In these cases only one of these have the intended effect, depending on order. How can I get my syntax correct to apply both of these options?
Test code (excluding imports):
chrome_options = webdriver.ChromeOptions();
chrome_options.add_experimental_option("prefs", {"excludeSwitches": ['enable-automation', 'load-extension']})
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get(('https://www.google.co.uk'))
Upvotes: 1
Views: 11788
Reputation: 51009
excludeSwitches is a list of strings
chrome_options.add_experimental_option('excludeSwitches', ['load-extension', 'enable-automation'])
Upvotes: 10