CDP Performance
Chrome DevTools Protocol (CDP) Performance API to capture metrics.
Selenium 4 uses the Chrome DevTools Protocol (CDP) which has a "Performance.getMetrics"
command! Pylenium provides a simple wrapper to capture these metrics.
Syntax
py.cdp.get_performance_metrics() -> Dict
Usage
The Dictionary of performance metrics returned includes metrics like:
ScriptDuration
ThreadTime
ProcessTime
DomContentLoaded
metrics = py.cdp.get_performance_metrics()
{'metrics':
[
{'name': 'Timestamp', 'value': 425608.80694},
{'name': 'AudioHandlers', 'value': 0},
{'name': 'ThreadTime', 'value': 0.002074},
...
]
}
Arguments
None
Yields
Dict
Examples
def test_capture_performance_metrics(py: Pylenium):
py.visit("https://qap.dev")
metrics = py.cdp.get_performance_metrics()["metrics"]
assert metrics
assert metrics[0]["name"] == "Timestamp"
assert metrics[0]["value"] > 0
Last updated