Test Overview
This test opens a browser using Selenium WebDriver, navigates to a sample website, finds a button, clicks it, and verifies the page title changes as expected. It demonstrates WebDriver usage. Grid and IDE are explained in the insight.
This test opens a browser using Selenium WebDriver, navigates to a sample website, finds a button, clicks it, and verifies the page title changes as expected. It demonstrates WebDriver usage. Grid and IDE are explained in the insight.
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 TestButtonClick(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.implicitly_wait(5) def test_click_button_changes_title(self): self.driver.get('https://example.com') button = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.ID, 'start-button')) ) button.click() WebDriverWait(self.driver, 10).until( EC.title_is('Example Domain - Started') ) self.assertEqual(self.driver.title, 'Example Domain - Started') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome WebDriver is launched | Chrome browser window opens, ready to navigate | - | PASS |
| 2 | Browser navigates to 'https://example.com' | Page loads with title 'Example Domain' | - | PASS |
| 3 | Waits until button with ID 'start-button' is clickable | Button is visible and enabled on the page | Button is found and clickable | PASS |
| 4 | Clicks the 'start-button' | Page reacts to click, title expected to change | - | PASS |
| 5 | Waits until page title changes to 'Example Domain - Started' | Page title updates accordingly | Title is exactly 'Example Domain - Started' | PASS |
| 6 | Asserts that the page title is 'Example Domain - Started' | Title matches expected value | assertEqual passes | PASS |
| 7 | Test ends and browser closes | Browser window closes cleanly | - | PASS |