0
0
Testing Fundamentalstesting~10 mins

Building a testing portfolio in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
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'.

Test Code - Selenium with unittest
Testing Fundamentals
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()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts and Chrome browser opensChrome browser window is open and ready-PASS
2Browser navigates to 'http://localhost:8000/portfolio.html'Portfolio webpage loads in browser-PASS
3Wait until element with ID 'about-me' is present'About Me' section is present on the pageCheck if 'About Me' section is visiblePASS
4Wait until element with ID 'projects' is present'Projects' section is present on the pageCheck if 'Projects' section is visiblePASS
5Test ends and browser closesBrowser window is closed-PASS
Failure Scenario
Failing Condition: The 'projects' section is missing from the portfolio page
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test check first after loading the portfolio page?
AIf the page title is correct
BIf the browser window is maximized
CIf the 'About Me' section is visible
DIf the 'Contact' section is present
Key Result
Always verify key sections or elements exist and are visible on your portfolio page to ensure it loads correctly for visitors.