Test Overview
This test checks if the test environment is correctly set up before running any tests. It verifies that the browser opens, the test URL loads, and the main page elements are present.
This test checks if the test environment is correctly set up before running any tests. It verifies that the browser opens, the test URL loads, and the main page elements are present.
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 TestEnvironmentSetup(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.implicitly_wait(5) def test_environment_ready(self): driver = self.driver driver.get('https://example.com') WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, 'h1'))) heading = driver.find_element(By.TAG_NAME, 'h1') self.assertTrue(heading.is_displayed()) def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and WebDriver Chrome instance is created | Browser window opens, ready for commands | - | PASS |
| 2 | Browser navigates to 'https://example.com' | Browser loads the example.com homepage | - | PASS |
| 3 | Waits up to 10 seconds for the <h1> element to be present | <h1> element appears on the page | Checks presence of <h1> element | PASS |
| 4 | Finds the <h1> element and checks if it is displayed | <h1> element is visible on the page | Assert that heading.is_displayed() is True | PASS |
| 5 | Test ends and browser closes | Browser window closes | - | PASS |