Scripts for testing navigation, page loads, and user flows.
Navigation test scripts focus on:
- Page load verification
- Navigation flow testing
- Link validation
- Page transition testing
- User flow simulation
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver.get("https://example.com")
# Wait for page title
WebDriverWait(driver, 10).until(
EC.title_contains("Expected Title")
)
# Verify current URL
assert "example.com" in driver.current_url# Navigate through multiple pages
driver.get("https://example.com")
assert driver.title == "Home"
# Click navigation link
link = driver.find_element(By.LINK_TEXT, "About")
link.click()
assert driver.title == "About"
# Click back button
driver.back()
assert driver.title == "Home"from selenium.webdriver.common.by import By
# Verify element presence
header = driver.find_element(By.CLASS_NAME, "header")
assert header is not None
# Verify element visibility
assert header.is_displayed()
# Verify element enabled
assert header.is_enabled()- selenium: Browser automation
- pytest: Test framework
- pytest-selenium: Selenium pytest plugin
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
class TestNavigation:
@pytest.fixture(autouse=True)
def setup(self):
self.driver = webdriver.Chrome()
yield
self.driver.quit()
def test_home_page_load(self):
self.driver.get("https://example.com")
assert "Example" in self.driver.title
def test_navigation_to_about(self):
self.driver.get("https://example.com")
link = self.driver.find_element(By.LINK_TEXT, "About")
link.click()
assert "about" in self.driver.current_urlUse descriptive names:
test_*.pyfor test scriptsnavigate_*.pyfor navigation scriptsverify_*.pyfor verification scripts