Skip to content

Introduction to Selenium WebDriver

Use Selenium when:

  • content is rendered by JavaScript
  • you must interact with forms/buttons

For static pages, prefer requests + BeautifulSoup.

selenium_basic.py
from selenium import webdriver
from selenium.webdriver.common.by import By
 
 
driver = webdriver.Chrome()  # requires chromedriver setup
try:
    driver.get("https://example.com")
    h1 = driver.find_element(By.TAG_NAME, "h1")
    print(h1.text)
finally:
    driver.quit()
  • Driver setup differs by OS
  • Consider headless mode for automation jobs

Exercise 2 – Join Paths with os.path.join

Section titled “Exercise 2 – Join Paths with os.path.join”

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading