Test Overview
This test simulates a beginner creating and verifying a simple testing portfolio webpage. It checks if the portfolio page loads correctly and contains key sections like 'About Me' and 'Projects'.
This test simulates a beginner creating and verifying a simple testing portfolio webpage. It checks if the portfolio page loads correctly and contains key sections like 'About Me' and 'Projects'.
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import unittest class PortfolioTest(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('http://localhost:8000/portfolio.html') def test_portfolio_sections(self): driver = self.driver wait = WebDriverWait(driver, 10) # Wait for About Me section about_me = wait.until(EC.presence_of_element_located((By.ID, 'about-me'))) self.assertTrue(about_me.is_displayed(), 'About Me section should be visible') # Wait for Projects section projects = wait.until(EC.presence_of_element_located((By.ID, 'projects'))) self.assertTrue(projects.is_displayed(), 'Projects section should be visible') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome browser opens | Chrome browser window is open and ready | - | PASS |
| 2 | Browser navigates to 'http://localhost:8000/portfolio.html' | Portfolio webpage loads in browser | - | PASS |
| 3 | Wait until element with ID 'about-me' is present | 'About Me' section is present on the page | Check if 'About Me' section is visible | PASS |
| 4 | Wait until element with ID 'projects' is present | 'Projects' section is present on the page | Check if 'Projects' section is visible | PASS |
| 5 | Test ends and browser closes | Browser window is closed | - | PASS |