Skip to content

Latest commit

 

History

History
100 lines (76 loc) · 2.19 KB

File metadata and controls

100 lines (76 loc) · 2.19 KB

Navigation and Page Load Tests

Scripts for testing navigation, page loads, and user flows.

Purpose

Navigation test scripts focus on:

  • Page load verification
  • Navigation flow testing
  • Link validation
  • Page transition testing
  • User flow simulation

Common Patterns

Verify Page Load

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

Test Navigation Flow

# 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"

Check Page Elements

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()

Recommended Packages

  • selenium: Browser automation
  • pytest: Test framework
  • pytest-selenium: Selenium pytest plugin

Testing Framework Example

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_url

File Naming

Use descriptive names:

  • test_*.py for test scripts
  • navigate_*.py for navigation scripts
  • verify_*.py for verification scripts