Anatomy of a test: from test case to code

Knowledge Videos

Short animated explainers, organised by subject.

Anatomy of a test: from test case to code

Map a manual test case to a Playwright test: the title, the steps as awaited actions, the expected result as an assertion, and how a pass or a failure looks.

Transcript

Here is a manual test case: a title, some steps, and an expected result. A Playwright test has exactly the same parts.

The title becomes the first argument of test. The steps go inside a function, between curly braces. Playwright hands you page, which is the browser tab it controls.

Each step becomes one line. Go to the login page with page dot goto. Fill in the email and the password. Click the Log in button. Every line starts with await, which means: finish this step before the next one.

The expected result becomes an assertion. Expect the page to have the U R L slash products. If the check is wrong, the test fails, just like a failed step on your test sheet.

Run it, and every step happens in a real browser. Green means every step and every check passed. Red shows you exactly which line failed, and why.

Remember: the title is the test name, the steps are awaited actions, and the expected result is an expect.

More in this series