1

I want to use ChromeDriver Performance Log to monitor network traffic.

I'm looking for some usage like this:

capabilities = DesiredCapabilities.CHROME

# enable performance log
capabilities['loggingPrefs'] = {"performance","all"}
self.driver = webdriver.Chrome(
    desired_capabilities=capabilities
)

# get performance log
logs = driver.get_log("performance")

Since my version of selenium 4.10.0

desired_capabilities property is Deprecated.

webdriver.Chrome(service=service, options=opts)

This option is allowed but I could not use desired_capabilities

I want to know how to setup desired_capabilities to Chrome or how to open Performance Log in order to trace traffic details.

Gugu72
  • 2,052
  • 13
  • 35
jeri neal
  • 33
  • 3
  • desired_capabitlites parameter might have been merged into options as you mentioned. You might want to check [this change](https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/#after) and [this example](https://www.selenium.dev/documentation/webdriver/drivers/options/#proxy), and [this one about performance metrics](https://www.selenium.dev/documentation/webdriver/bidirectional/chrome_devtools/#collect-performance-metrics) – Reyot Jul 15 '23 at 20:39

1 Answers1

0

DesiredCapabilities earlier deprecated, is now completely removed in Selenium v4.10.


Solution

You have to use an instance of ChromeOptions and the set_capability() method as follows:

from selenium.webdriver.chrome.options import Options

options = Options()
options.set_capability('goog:loggingPrefs', {'performance': 'ALL'})
# other configurations
driver = Chrome(service=service, options=options)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352