Chrome DevTools Recorder: How to Use and Export Tests
In this article
The Chrome DevTools Recorder panel is used to record a sequence of user interactions—such as clicks, typing, and navigation—and replay them to verify website behavior or export them as automated test scripts. To use it, open DevTools (F12), navigate to the Recorder tab, click "Start recording," perform your actions on the page, and then click "End recording" to save the flow for playback or export.
Background and Purpose of the Recorder
Historically, creating automated end-to-end (E2E) tests required developers to manually write scripts using frameworks like Selenium, Puppeteer, or Playwright. This process often involved tedious manual inspection of the DOM to find unique CSS selectors or XPaths for every single element the test needed to interact with. The Recorder panel simplifies this by acting as a "low-code" bridge between manual testing and automated scripting.
By capturing the actual events triggered by a user's mouse and keyboard, the Recorder generates a JSON-based representation of the user journey. This is particularly useful for regression testing, where a developer needs to ensure that a new code change hasn't broken a critical path, such as a checkout process or a sign-up form, without writing a full test suite from scratch.
Step-by-Step Guide to Recording a Flow
Following these steps allows you to capture a precise sequence of events that can be replayed exactly as they occurred.
- Open the Recorder Panel: Open Chrome DevTools. If the "Recorder" tab is not visible in the top navigation bar, click the "More tabs" chevron ( 5b8 ) or press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) and type "Show Recorder". - Initiate Recording: Click the "Start recording" button. A dialog box will appear asking you to name your recording. Give it a descriptive name (e.g., "User Login Flow") and click "Start recording".
- Perform Actions: Interact with the web page as a user would. Click buttons, fill out forms, and navigate through different pages. The Recorder captures these events in real-time, listing them in the panel.
- Stop and Review: Once the sequence is complete, click the "End recording" button in the DevTools panel. You will now see a list of all recorded steps, including the action performed and the selector used to identify the element.
Replaying and Editing Recorded Flows
Once a flow is recorded, it is not static. You can verify the recording or tweak it to make it more robust before exporting it to a professional testing framework.
- Replaying: Click the "Replay" button. Chrome will automatically perform the actions at the speed you specify. This is an excellent way to verify that the recorded selectors are still valid after a UI change.
- Editing Selectors: If a replay fails because an element's ID changed, you can double-click the selector in the Recorder list and manually update it to a more stable CSS selector.
- Adding Custom Steps: You can manually add steps to the flow, such as adding a "Wait for element" step to handle asynchronous loading or API calls that might cause a race condition during replay.
- Deleting Steps: Unnecessary clicks or accidental movements can be removed by right-clicking the specific step and selecting "Delete".
Exporting to Automation Frameworks
The true power of the Recorder lies in its ability to export recordings into industry-standard code. Instead of manually translating a recording into a script, you can use the "Export" menu.
Currently, the Recorder supports exporting to several formats, most notably Puppeteer and potentially other extensions for Playwright or Cypress. When you export to Puppeteer, Chrome generates a JavaScript file containing the async functions and selectors necessary to run the test in a headless browser environment. This allows developers to move from a manual recording in a browser to a CI/CD pipeline where the test runs automatically on every commit.
Common Problems and Troubleshooting
While the Recorder is powerful, certain web architectures can cause recording or replay failures.
- Dynamic Selectors: Many modern frameworks (like React or Angular) generate dynamic IDs (e.g.,
id="button-12345") that change every time the page reloads. If the Recorder captures these, the replay will fail. The solution is to manually edit the selector to use a more stable attribute, such as[data-testid="submit-button"]. - Iframe Issues: Interactions inside iframes can sometimes be tricky for the Recorder to track accurately. Ensure the iframe is fully loaded before interacting with its contents.
- Timing and Latency: A recording might work perfectly during the initial capture but fail during replay because the network is slower. Adding manual delays or "Wait for element" steps is the primary way to resolve these timing issues.
- Authentication State: The Recorder does not automatically save cookies or session tokens for the replay. If your flow requires being logged in, you must either be logged in during the replay or include the login steps as part of the recording.
Comparing Recorder to Traditional Testing
It is important to understand that the Recorder is a tool for generating tests, not a replacement for a comprehensive testing strategy. Traditional manual scripting allows for complex logic, such as conditional loops (if/else) and data-driven testing (running the same test with 100 different usernames), which the Recorder cannot do natively.
However, the Recorder drastically reduces the "time to first test." It eliminates the friction of looking up selectors and writing boilerplate code, making it an ideal starting point for developers who are not experts in E2E testing frameworks but need to ensure basic functionality remains intact.
Frequently Asked Questions
Does the Recorder work on all websites?
Yes, the Recorder works on any website accessible via Chrome. However, its effectiveness depends on how the website is built; sites with highly dynamic content or complex shadow DOMs may require more manual selector editing.
Can I share my recordings with other developers?
Yes. You can export the recording as a JSON file. Another developer can then import that JSON file into their own Chrome DevTools Recorder panel to replay the exact same sequence of events.
Is the Recorder panel a replacement for Selenium?
No, it is a helper tool. While it can export code that functions similarly to Selenium or Puppeteer, it lacks the advanced orchestration, reporting, and cross-browser capabilities of a full testing framework.
Why did my recording fail during replay?
The most common reason is a change in the DOM. If a class name or ID changed between the time of recording and the time of replay, Chrome cannot find the element. Check the failed step in the Recorder panel to see which selector is causing the error.
Do I need to install any extensions to use the Recorder?
No, the Recorder is a built-in feature of Chrome DevTools. As long as you are using a recent version of Google Chrome, the panel is available by default without any additional installations.