启动 Selenium Chromedriver 时使用两个 excludeSwitches?

1 python selenium google-chrome selenium-chromedriver selenium-webdriver

我的目标是使用 Chrome 作为服务在屏幕上显示全屏网页。我正在通过创建一个 python 脚本来解决这个挑战,该脚本使用 Selenium 将 chrome 定向到正确的页面,并正确设置站点格式。由于主要要求是显示,因此显示的网页畅通无阻非常重要。在我的实例中有两个障碍,都可以通过使用不同的 excludeSwitches 选项来处理:

要禁用自动化栏:

chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']);
Run Code Online (Sandbox Code Playgroud)

要禁用“禁用开发者模式扩展”弹出窗口:

chrome_options.add_experimental_option("excludeSwitches", ['load-extension'])
Run Code Online (Sandbox Code Playgroud)

但是我还没有找到同时实现两者的方法 - 我试过:

chrome_options.add_experimental_option("prefs", {"excludeSwitches": ['enable-automation'], "excludeSwitches": ['load-extension']});
Run Code Online (Sandbox Code Playgroud)
prefs = {"excludeSwitches": ['enable-automation, load-extension'], "excludeSwitches": ['load-extension', 'enable-automation']}

chrome_options.add_experimental_option("prefs", prefs);
Run Code Online (Sandbox Code Playgroud)

在这些情况下,根据顺序,只有其中之一具有预期效果。如何让我的语法正确以应用这两个选项?

测试代码(不包括进口):

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'))
Run Code Online (Sandbox Code Playgroud)

Guy*_*Guy 6

excludeSwitches是一个字符串列表

chrome_options.add_experimental_option('excludeSwitches', ['load-extension', 'enable-automation'])
Run Code Online (Sandbox Code Playgroud)