0
0
Selenium Javatesting~20 mins

Performance metrics via DevTools in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DevTools Performance Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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.
Selenium Java
DevTools devTools = driver.getDevTools();
devTools.createSession();

Map<String, Object> metrics = devTools.send(Page.getMetrics());
System.out.println(metrics.get("Timestamp"));
APrints a double value representing the timestamp in seconds since navigation start
BPrints a string with the page title
CThrows a NullPointerException because getMetrics() returns null
DPrints an integer representing the number of metrics collected
Attempts:
2 left
💡 Hint
Think about what the 'Timestamp' metric represents in DevTools metrics.
assertion
intermediate
2: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");
AassertFalse(domContentLoaded > 5);
BassertEquals(5, domContentLoaded, 0.1);
CassertTrue(domContentLoaded < 5, "DomContentLoaded should be less than 5 seconds");
DassertNotNull(domContentLoaded);
Attempts:
2 left
💡 Hint
You want to check if the value is less than 5 seconds.
🔧 Debug
advanced
2: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());
AThe driver instance is null
BYou forgot to call devTools.createSession() before sending commands
CPage.getMetrics() is deprecated and cannot be used
DYou need to cast the driver to ChromeDriver first
Attempts:
2 left
💡 Hint
DevTools commands require an active session.
🧠 Conceptual
advanced
2: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?
AAfter waiting for the 'load' event or a specific element to be visible
BBefore calling driver.get(url)
CImmediately after driver.get(url) returns
DAfter closing the browser
Attempts:
2 left
💡 Hint
Think about when the page is fully loaded and metrics are stable.
framework
expert
2: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?
ACollect metrics after driver.quit() in @AfterAll method
BCollect metrics once in a static block before all tests run
CCollect metrics only in the first test method and reuse for others
DCreate a @BeforeEach method to start DevTools session and a @AfterEach method to collect and log metrics
Attempts:
2 left
💡 Hint
Think about test isolation and per-test reporting.