-
Notifications
You must be signed in to change notification settings - Fork 50
Add functions to measure how long an action takes #260
Copy link
Copy link
Open
Labels
beginnerSmall - requires some line changes and a test or twoSmall - requires some line changes and a test or twoenhancementNew feature or requestNew feature or requesthacktoberfest-acceptedHacktoberfest!Hacktoberfest!
Description
Should we add performance.mark() and performance.measure() functions to measure an action's performance?
Filip Hric posted an article about doing this with Cypress: https://filiphric.com/testing-frontend-performance-with-cypress
This is different than our WebPerformance metrics or the Chrome DevTools Protocol performance metrics since this is based on an action and the user has the ability to set it.
This is similar to the stopwatch decorator we have (I want to change this decorator too though...), but would be based on the browser's perception instead of the current thread running the test. Is this a good idea? Would this be useful?
Filip's example would look something like this:
def add_to_cart(name: str, quantity: int)
py.get(f"#{name}").click()
py.get("#qty").type(quantity)
py.get("#add-to-cart-btn").click()
def test_action_duration(py: Pylenium):
py.visit("https://some-ecommerce-website.com")
py.performance.mark("custom name")
py.add_to_cart("ball", 2)
time = py.performance.measure("custom name")
assert time < 5, "Took longer than 5 seconds to add item to cart"Or we could use a decorator approach as well
@performance.mark("custom name")
def add_to_cart(name: str, quantity: int):
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
beginnerSmall - requires some line changes and a test or twoSmall - requires some line changes and a test or twoenhancementNew feature or requestNew feature or requesthacktoberfest-acceptedHacktoberfest!Hacktoberfest!