def _process_chrome_options(self, opts):
if isinstance(opts, ChromeOptions):
options = opts
else:
options = ChromeOptions()
if 'args' in opts:
for arg in opts.pop('args'):
options.add_argument(arg)
if 'headless' in opts:
options.set_headless()
if 'binary' in opts or 'binary_location' in opts:
options.binary_location = opts.pop('binary') or opts.pop('binary_location')
if 'debugger_address' in opts:
options.debugger_address = opts.pop('debugger_address')
if 'extensions' in opts:
for path in opts.pop('extensions'):
options.add_extension(path)
if 'encoded_extensions' in opts:
for string in opts.pop('encoded_extensions'):
options.add_encoded_extension(string)
if 'experimental_options' in opts:
for name, value in opts.pop('experimental_options').items():
options.add_experimental_option(name, value)
self.selenium_opts['options'] = options
评论列表
文章目录