Testing career progression in Testing Fundamentals - Build an Automation Script
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 TestCareerProgressionPage(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/testing-career-progression') self.wait = WebDriverWait(self.driver, 10) def test_career_progression_display(self): driver = self.driver wait = self.wait # Wait for the career levels section career_section = wait.until(EC.visibility_of_element_located((By.ID, 'career-levels'))) # Verify career levels text career_levels_text = career_section.text self.assertIn('Junior Tester', career_levels_text, 'Junior Tester level missing') self.assertIn('Senior Tester', career_levels_text, 'Senior Tester level missing') self.assertIn('Test Lead', career_levels_text, 'Test Lead level missing') # Click Senior Tester to expand details senior_tester_element = career_section.find_element(By.XPATH, ".//div[contains(text(), 'Senior Tester')]") senior_tester_element.click() # Verify details appear details = wait.until(EC.visibility_of_element_located((By.ID, 'senior-tester-details'))) details_text = details.text self.assertIn('responsibilities', details_text.lower(), 'Responsibilities missing in Senior Tester details') self.assertIn('skills', details_text.lower(), 'Skills missing in Senior Tester details') # Verify Next Steps section next_steps = wait.until(EC.visibility_of_element_located((By.ID, 'next-steps'))) next_steps_text = next_steps.text self.assertIn('advance from Junior to Senior Tester', next_steps_text, 'Advancement guidance missing') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
This test script uses Selenium with Python and unittest framework.
In setUp, it opens the Testing Career Progression page and sets an explicit wait.
The test test_career_progression_display waits for the career levels section to appear, then checks that the expected career levels text is present.
It clicks the 'Senior Tester' element to expand details, then waits for and verifies that the details contain 'responsibilities' and 'skills'.
Finally, it checks the 'Next Steps' section for guidance text on advancing from Junior to Senior Tester.
Explicit waits ensure elements are ready before interacting, and assertions have clear messages to help identify failures.
The tearDown method closes the browser after the test.
Now add data-driven testing with 3 different career levels to verify their details expand correctly