Block 135: Selenium: Browser Automation
Automate browser interactions with Selenium.
Concepts
- pip install selenium + webdriver setup
- driver.get(), driver.find_element(), driver.click()
- By.ID, By.CLASS_NAME, By.CSS_SELECTOR, By.XPATH
- Handling waits: WebDriverWait and expected_conditions
Code Examples
See exercise below.
Exercise
Open a browser with Selenium, navigate to a URL, and take a screenshot. Find and click a button on a webpage programmatically.
Homework
What are 3 legitimate use cases for Selenium and 3 uses that would be unethical or against ToS?