Test Overview
This test performs a smoke test to check if the main features of the application load correctly. It then performs a sanity test to verify a specific feature works after a minor change.
This test performs a smoke test to check if the main features of the application load correctly. It then performs a sanity test to verify a specific feature works after a minor change.
import unittest 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 class SmokeSanityTest(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com') def test_smoke_and_sanity(self): driver = self.driver # Smoke Test: Check homepage title self.assertIn('Example Domain', driver.title) # Smoke Test: Check main heading is present heading = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.TAG_NAME, 'h1')) ) self.assertEqual(heading.text, 'Example Domain') # Sanity Test: Click More Information link and verify URL more_info_link = driver.find_element(By.CSS_SELECTOR, 'a') more_info_link.click() WebDriverWait(driver, 10).until( EC.url_contains('iana.org/domains/example') ) self.assertIn('iana.org/domains/example', driver.current_url) def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and browser opens Chrome | Chrome browser window opens at https://example.com homepage | - | PASS |
| 2 | Check homepage title contains 'Example Domain' | Browser shows homepage with title 'Example Domain' | Assert 'Example Domain' in page title | PASS |
| 3 | Wait for main heading <h1> to be present | Page loaded with visible main heading | Assert heading text equals 'Example Domain' | PASS |
| 4 | Find and click the 'More Information' link | User clicks link on homepage | - | PASS |
| 5 | Wait until URL contains 'iana.org/domains/example' | Browser navigates to IANA example domains page | Assert current URL contains 'iana.org/domains/example' | PASS |
| 6 | Test ends and browser closes | Browser window closes | - | PASS |