Chapter 06: Strings and template literals
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Strings and template literals
Strings represent text such as a page title or a username. Methods like trim, includes and toLowerCase return new values rather than modifying the original string. Template literals use backticks and interpolation to build readable messages.
How it works
Step-by-step walkthrough
- Normalize a string
- Check for text
- Interpolate a message
Example
const title = ' TestingDocs ';
const clean = title.trim();
console.log(`Page: ${clean}`);
console.log(clean.includes('Docs'));Remember that string comparisons are case-sensitive.
✎ Your practice task
Check whether clean starts with Testing.
Knowledge check
Which method removes surrounding whitespace?
🌐 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.