Manuals / Selenium WebDriver / Chapter 2

A · WebDriver Core · beginner · Week 1 · Chapter 2 of 12

WebDriver mental model & first script

Driver talks to browser via W3C WebDriver protocol. Sessions, findElement, click, sendKeys. Always quit driver in finally hook.

Path progress
11%

Step 1 of 3

Hello WebDriver

Selenium Manager auto-downloads drivers (Selenium 4.6+). Start Chrome, open page, assert title, quit.

Hello WebDriverDrag 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 →Hello WebDriverdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

# Python
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
try:
    driver.get("https://the-internet.herokuapp.com/")
    assert "Internet" in driver.title
finally:
    driver.quit()

Do this now

Script: open the-internet.herokuapp.com, assert title contains "Internet", quit in finally.

Was this step clear?
Chapter learning outcomes
  • Driver lifecycle
  • By locators
  • First navigation and assert

Clear these before you leave

Side quest

Form submit

the-internet.herokuapp.com/login — valid and invalid credentials.