If you are using Selenium, use browser.get_log to obtain all performance logs. My solution uses Python, but it should be similar for any supported language.
First, set up headless Chrome:
from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = webdriver.ChromeOptions() chrome_options.set_headless(True) # for possible entries refer to current implementation at # https://chromium.googlesource.com/chromium/src/+/master/chrome/test/chromedriver/capabilities.cc#372 perfLogPrefs = { "traceCategories": "toplevel,disabled-by-default-devtools.timeline.frame,blink.console,disabled-by-default-devtools.timeline,benchmark" } chrome_options.add_experimental_option("perfLoggingPrefs", perfLogPrefs) desired_capabilities = chrome_options.to_capabilities() desired_capabilities['loggingPrefs'] = { "browser": "ALL", # use this for console.log output, and obtain later "performance": "ALL", } browser = webdriver.Chrome( chrome_options=chrome_options, desired_capabilities=desired_capabilities)
After the tests are finished, obtain logs using get_log and extract the entries:
# based more or less on # https://sites.google.com/a/chromium.org/chromedriver/logging/performance-log#TOC-Collecting-Log-Entries import json with open(base_filename + '.perf.log', 'w') as f: logs = browser.get_log('performance') f.write('[') add_comma = False for entry in logs: if add_comma: f.write(',\n') message = json.loads(entry['message'])['message'] json.dump(message['params'], f) add_comma = True f.write(']')
The entries are similar to ones described in Trace Event Format documentation. However, I can't figure out the proper file format to load it later in Chrome DevTools Performance tab. I get an error:
Malformed timeline data: TypeError: Cannot read property 'split' of undefined
If someone manages to load that in Chrome, please update my answer (or post answer in How to visualize log of chrome DevTool protocol messages?).
window.performanceis your friend.performance.getEntriesByType("resource")should get you the details you're looking for. I'm not talking aboutperformance.navigationorperformance.timing