Why continuous learning advances careers in Testing Fundamentals - Automation Benefits in Action
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 TestContinuousLearningSection(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example-learning-platform.com/career-advancement') self.wait = WebDriverWait(self.driver, 10) def test_continuous_learning_section(self): driver = self.driver wait = self.wait # Wait for the section title to be visible section_title = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'section#continuous-learning h2'))) self.assertEqual(section_title.text.strip(), 'Why continuous learning advances careers') # Locate the benefits list benefits = driver.find_elements(By.CSS_SELECTOR, 'section#continuous-learning ul li') self.assertGreaterEqual(len(benefits), 3, 'Less than 3 benefits found') # Check each benefit text is not empty for benefit in benefits: self.assertTrue(benefit.text.strip(), 'Benefit text should not be empty') # Verify the section content is visible section = driver.find_element(By.ID, 'continuous-learning') self.assertTrue(section.is_displayed(), 'Section should be visible') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
This test script uses Selenium with Python's unittest framework.
In setUp, it opens the browser and navigates to the career advancement page.
The test waits explicitly for the section title to appear, ensuring the page is loaded properly.
It asserts the title text matches exactly the expected heading.
Then it finds the list items under the section and checks there are at least three benefits listed.
Each benefit's text is checked to be non-empty to ensure meaningful content.
Finally, it confirms the entire section is visible on the page.
The tearDown method closes the browser after the test.
This approach uses explicit waits and clear locators for reliability and readability.
Now add data-driven testing with 3 different page URLs where the section might appear