也许有人遇到了这个问题。。。我使用PyTest的自定义"chrome驱动程序"one_answers"性能"日志:
cap = webdriver.DesiredCapabilities.CHROME.copy()
cap['goog:loggingPrefs'] = {'performance': 'ALL'}
services = Service(executable_path='/usr/local/bin/chromedriver')
chrome_driver = webdriver.Chrome(desired_capabilities=cap, options=options, service=services)
我的环境:
- 硒4.0.0
- 色度河95.0.4638.17
现在我收到了一个警告:
=============================== warnings summary ===============================
tests/test_name.py::test_main[/]
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:69: DeprecationWarning: desired_capabilities has been deprecated, please pass in a Service object
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 1 passed, 1 warning in 10.49s =========================
可能有人知道如何处理这件事?
见下文
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
options = webdriver.ChromeOptions()
options.set_capability("loggingPrefs", {'performance': 'ALL'})
service = ChromeService(executable_path'/usr/local/bin/chromedriver')
driver = webdriver.Chrome(service=service, options=options)
如果以上不起作用,请尝试:
options.set_capability("goog:loggingPrefs", {'performance': 'ALL'})