Chapter 21: Promise.all and asynchronous workflows
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Promise.all and asynchronous workflows
Promise.all awaits a group of independent promises, preserving input order in its result array. It rejects if any input rejects. Sequential await is preferable for dependent actions such as filling a form and submitting it.
How it works
Step-by-step walkthrough
- Prepare independent promises
- Await their combined result
- Print both values
Example
async function run() {
const results = await Promise.all([
Promise.resolve('A'), Promise.resolve('B')
]);
console.log(results);
}
run().catch(console.error);Do not parallelize browser actions that depend on each other.
✎ Your practice task
Change one promise to reject and handle it.
Knowledge check
Does Promise.all preserve input result order?
🌐 Continue learning
60-chapter learning path
Start at chapter 1, or choose any topic. Your progress is tracked separately for each chapter.
JavaScript fundamentals
TypeScript fundamentals
Playwright • setup & locators
Playwright • interactions & assertions
Playwright • framework & debugging
Playwright • real-world automation
Interactive practice lab
Try the controls below and observe the corresponding Playwright locator instructions. This browser demo does not execute Node.js or Playwright Test; copy the code to your local Playwright project to automate it.
Task manager demo
Suggested automation
Actions on the demo update these examples. In your local test use a page that contains the same controls.
Download a standalone lab page, then serve it locally (for example with Python's http.server). Navigate to it in a Playwright test.