Test Overview
This test opens a web page, finds a text input box, types the text "Hello World" into it, and verifies that the input box contains the typed text.
This test opens a web page, finds a text input box, types the text "Hello World" into it, and verifies that the input box contains the typed text.
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 TestTypingText(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/input') def test_typing_text(self): driver = self.driver wait = WebDriverWait(driver, 10) input_box = wait.until(EC.presence_of_element_located((By.ID, 'text-input'))) input_box.clear() input_box.send_keys('Hello World') self.assertEqual(input_box.get_attribute('value'), 'Hello World') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome browser opens | Browser window is open, ready to load the page | - | PASS |
| 2 | Navigates to URL 'https://example.com/input' | Page with input box loaded and visible | - | PASS |
| 3 | Waits until element with ID 'text-input' is present | Input box is found on the page | Element with ID 'text-input' is present | PASS |
| 4 | Clears any existing text in the input box | Input box is empty | - | PASS |
| 5 | Types text 'Hello World' into the input box using send_keys | Input box shows text 'Hello World' | - | PASS |
| 6 | Checks that the input box value is exactly 'Hello World' | Input box value attribute equals 'Hello World' | Assert input_box.get_attribute('value') == 'Hello World' | PASS |
| 7 | Test ends and browser closes | Browser window closed | - | PASS |