chromeOptions 是一个配置 chrome 启动是属性的类。通过这个类,我们可以为 chrome 配置如下参数(这个部分可以通过 selenium 源码看到):
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
class Options(object):
KEY = "goog:chromeOptions"
def __init__(self):
self._binary_location = ''
self._arguments = []
self._extension_files = []
self._extensions = []
self._experimental_options = {}
self._debugger_address = None
self._caps = DesiredCapabilities.CHROME.copy()
def add_experimental_option(self, name, value):
"""
Adds an experimental option which is passed to chrome.
Args:
name: The experimental option name.
value: The option value.
"""
self._experimental_options[name] = value