Manuals / Selenium WebDriver / Chapter 7

C · Test Infrastructure · intermediate · Week 5–6 · Chapter 7 of 12

Test runners — pytest, TestNG, or JUnit

Raw scripts do not scale. Test runners give discovery, reporting, markers, and parallel hooks.

Path progress
52%

Step 1 of 4

pytest or TestNG setup

pytest: tests/test_*.py, assert keywords. TestNG: @Test annotations, testng.xml suite.

pytest or TestNG setupDrag 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 →pytest or TestNG sdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

# pytest.ini
[pytest]
markers =
    smoke: quick checks
    regression: full suite

Do this now

Organize tests under tests/. Run full suite with one command.

Was this step clear?
Chapter learning outcomes
  • Test discovery
  • Markers / groups
  • HTML reports
  • Parametrize data-driven tests

Clear these before you leave

Side quest

Data-driven login

5 credential rows, 5 outcomes (pass/fail messages).