Challenge - 5 Problems
DevTools Performance Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Understanding DevTools Performance Metrics Retrieval
What will be the output of the following Java Selenium code snippet that uses Chrome DevTools Protocol to get the page load time metric?
Assume the page fully loads and metrics are available.
Assume the page fully loads and metrics are available.
Selenium Java
DevTools devTools = driver.getDevTools();
devTools.createSession();
Map<String, Object> metrics = devTools.send(Page.getMetrics());
System.out.println(metrics.get("Timestamp"));Attempts:
2 left
💡 Hint
Think about what the 'Timestamp' metric represents in DevTools metrics.
✗ Incorrect
The 'Timestamp' metric from DevTools is a double value representing the time in seconds since the navigation started. The code prints this value. Other options are incorrect because getMetrics() returns a map of metrics, not page title or count, and it does not return null.
❓ assertion
intermediate2:00remaining
Correct Assertion for Page Load Time Metric
Which assertion correctly verifies that the page load time metric 'DomContentLoaded' is less than 5 seconds using JUnit in Selenium with DevTools?
Selenium Java
DevTools devTools = driver.getDevTools();
devTools.createSession();
Map<String, Object> metrics = devTools.send(Page.getMetrics());
Double domContentLoaded = (Double) metrics.get("DomContentLoaded");Attempts:
2 left
💡 Hint
You want to check if the value is less than 5 seconds.
✗ Incorrect
Option C correctly asserts that the DomContentLoaded metric is less than 5 seconds with a clear failure message. Option C checks equality which is not the requirement. Option C asserts false on greater than 5 which is logically correct but less clear. Option C only checks for null, not the value.
🔧 Debug
advanced2:00remaining
Debugging DevTools Session Creation Failure
You run the following Selenium Java code to start a DevTools session but get an IllegalStateException: "No active session found". What is the most likely cause?
Selenium Java
DevTools devTools = driver.getDevTools(); // Missing devTools.createSession(); Map<String, Object> metrics = devTools.send(Page.getMetrics());
Attempts:
2 left
💡 Hint
DevTools commands require an active session.
✗ Incorrect
DevTools commands require an active session created by devTools.createSession(). Without it, sending commands throws IllegalStateException. The driver being null or casting is unrelated. Page.getMetrics() is valid.
🧠 Conceptual
advanced2:00remaining
Understanding Performance Metrics Collection Timing
When using Selenium with Chrome DevTools Protocol to collect performance metrics, at what point is it best to capture the metrics to get accurate page load performance data?
Attempts:
2 left
💡 Hint
Think about when the page is fully loaded and metrics are stable.
✗ Incorrect
Performance metrics reflect page load events. Capturing them after the 'load' event or after a key element is visible ensures the page has fully loaded. Capturing immediately after driver.get(url) may be too early. Before driver.get(url) or after closing browser is invalid.
❓ framework
expert2:00remaining
Integrating DevTools Performance Metrics in Test Framework
You want to integrate Chrome DevTools performance metrics collection into a JUnit 5 Selenium test framework. Which approach ensures metrics are collected for each test and reported properly?
Attempts:
2 left
💡 Hint
Think about test isolation and per-test reporting.
✗ Incorrect
Starting and collecting metrics per test ensures isolation and accurate reporting. Collecting once or after all tests risks mixing data or missing metrics. Collecting after driver.quit() is too late.