You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pylenium now uses Selenium v4.1.0! The goal was to start leveraging Selenium 4 features and this release focused on the Performance metrics from the Chrome DevTools Protocol (CDP).
Highlights
Capturing web performance metrics is a powerful feature of web automation. Selenium 4 introduced the ability to leverage CDP which has a Performance API, but it has its limitations. Let's dive into examples because we provide a few ways to capture perf metrics 😄
We created a CDP class so you could call the API directly from Pylenium. Currently, there are only two methods:
# Run any command against the CDP API and get a result. (See the docs linked above for usage examples)execute_command(cmd: str, cmd_args: Dict) ->Dict# Return performance metrics like 'ScriptDuration', 'ThreadTime', 'ProcessTime', and 'DomContentLoaded'get_performance_metrics() ->Dict
⚠️ Selenium says that CDP is meant for Chrome and more experimental for now!
This is good to be aware of. CDP may not work for other browsers or if you're running remotely against something like Selenium Grid.
Pylenium Performance API
The limitations may prevent you from using CDP, but we've got you covered! Pylenium has a Performance API that you can use to capture metrics as well.
💡 Some of these metrics may not be from a "Standard", but they all use W3C objects like PaintTiming. So, you'll see that some of the calculations are made by us, but they have already been applied and used to provide insights and solve problems at a few companies (including Adobe 😎). I hope they can help you too!
Using it is easy as well!
perf=py.performance.get()
This returns a lot of data compared to CDP, so I recommend looking at the performance.py module to see all that's available!
Examples
💡 Calling this method too soon may yield NoneTypes because the browser hasn't generated them yet.
Store the entire WebPerformance object and print it as a dictionary
deftest_new_window_and_tab(py: Pylenium):
# Opens a new, empty browser window and switches to itpy.switch_to.new_window()
assertlen(py.window_handles) ==2# Opens a new, empty tab in the current browser window and switches to itpy.switch_to.new_tab()
assertlen(py.window_handles) ==3
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
v1.14.0 - 2022.01.27
Overview
Pylenium now uses
Selenium v4.1.0
! The goal was to start leveraging Selenium 4 features and this release focused on the Performance metrics from the Chrome DevTools Protocol (CDP).Highlights
Capturing web performance metrics is a powerful feature of web automation. Selenium 4 introduced the ability to leverage CDP which has a Performance API, but it has its limitations. Let's dive into examples because we provide a few ways to capture perf metrics 😄
Chrome DevTools Protocol (CDP)
We created a
CDP
class so you could call the API directly from Pylenium. Currently, there are only two methods:Using it is easy!
And in case you're wondering,
py.cdp.get_performance_metrics()
returns a dictionary that looks kinda like this:Limitations
This is good to be aware of. CDP may not work for other browsers or if you're running remotely against something like Selenium Grid.
Pylenium Performance API
The limitations may prevent you from using CDP, but we've got you covered! Pylenium has a Performance API that you can use to capture metrics as well.
Using it is easy as well!
This returns a lot of data compared to CDP, so I recommend looking at the performance.py module to see all that's available!
Examples
Store the entire WebPerformance object and print it as a dictionary
Get a single data point from WebPerformance
What else changed?
EdgeOptions
andEdgeService
towebdriver_factory
by @ElSnoMan in Add EdgeOptions and EdgeService to webdriver_factory #224new_window()
andnew_tab()
methods toSwitchTo
class by @ElSnoMan in Add new_window() and new_tab() methods to SwitchTo class #225This does exactly like what it sounds like 😄
This discussion was created from the release Add Chrome DevTools Protocol (CDP) for Performance metrics.
Beta Was this translation helpful? Give feedback.
All reactions