Manuals / Playwright with Python / Chapter 41

Part 6 · Pro-Level Practices · pro · ~40 min · Chapter 41 of 61

31. Code Review & Best Practices

Naming conventions, DRY principles # Avoid: def test1(page): ... # Prefer: descriptive, scenario-revealing names def test_login_fails_with_incorrect_password(page): ...

Path progress
66%

Step 1 of 3

Naming conventions, DRY principles

... ... Pointers: A test name should describe the scenario and expected outcome well enough that a failure notification alone (just the test name, no need to open the code) tells a reader roughly what broke. DRY (Don't Repeat Yourself) in this context mainly means: object method (Chapter 14) or a utility function (Chapter 29), not copy-pasted.

Naming conventions, DRY principlesDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Page under testdrag · tap →Multi-browserdrag · tap →Automation pathdrag · tap →Tooling nodedrag · tap →

Try it

Run / study this snippet

# Prefer: descriptive, scenario-revealing names
Was this step clear?
Chapter learning outcomes
  • Naming conventions, DRY principles
  • Common anti-patterns in automation
  • Documentation standards for shared frameworks

Clear these before you leave

Side quest

31. Code Review & Best Practices deliverable

Apply one idea from “Naming conventions, DRY principles” in a small script or note.