if executable_path != "chromedriver": warnings.warn( "executable_path has been deprecated, please pass in a Service object", DeprecationWarning, stacklevel=2 ) if chrome_options: warnings.warn("use options instead of chrome_options", DeprecationWarning, stacklevel=2) options = chrome_options if keep_alive != DEFAULT_KEEP_ALIVE: warnings.warn( "keep_alive has been deprecated, please pass in a Service object", DeprecationWarning, stacklevel=2 ) else: keep_alive = True if not service: service = Service(executable_path, port, service_args, service_log_path) super().__init__( DesiredCapabilities.CHROME["browserName"], "goog", port, options, service_args, desired_capabilities, service_log_path, service, keep_alive, )
时间: 2023-11-22 15:52:12 浏览: 35
chromedriver-win64_125.0.6422.76.zip
5星 · 资源好评率100%
这段代码是 Python 中的一个类初始化方法,用于创建一个 ChromeDriver 对象。其中,如果传入的 `executable_path` 不等于 "chromedriver",则会发出一个警告,提示使用 `Service` 对象代替;如果传入了 `chrome_options`,则会发出一个警告,提示使用 `options` 代替;如果传入的 `keep_alive` 不等于默认值,也会发出一个警告,提示使用 `Service` 对象代替。最后,根据传入的参数创建一个 `ChromeDriver` 对象并返回。
阅读全文