Test Overview
This test runs a simple Selenium test on a Selenium Grid. It opens a browser on a remote node, navigates to a page, clicks a button, and verifies the result.
This test runs a simple Selenium test on a Selenium Grid. It opens a browser on a remote node, navigates to a page, clicks a button, and verifies the result.
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 # Setup remote WebDriver to connect to Selenium Grid hub remote_url = "http://localhost:4444/wd/hub" capabilities = { "browserName": "chrome", "platformName": "ANY" } driver = webdriver.Remote(command_executor=remote_url, desired_capabilities=capabilities) try: driver.get("https://example.com") # Wait until the button is clickable wait = WebDriverWait(driver, 10) button = wait.until(EC.element_to_be_clickable((By.ID, "start-button"))) button.click() # Verify the result text appears result = wait.until(EC.visibility_of_element_located((By.ID, "result-text"))) assert result.text == "Test Passed", f"Expected 'Test Passed' but got '{result.text}'" finally: driver.quit()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Create Remote WebDriver session connecting to Selenium Grid hub at http://localhost:4444/wd/hub with Chrome capabilities | Remote browser node is allocated and ready | - | PASS |
| 2 | Navigate browser to https://example.com | Browser displays the example.com homepage | - | PASS |
| 3 | Wait up to 10 seconds for button with ID 'start-button' to be clickable | Button is visible and enabled on the page | Button is clickable | PASS |
| 4 | Click the 'start-button' | Button click triggers page update | - | PASS |
| 5 | Wait up to 10 seconds for element with ID 'result-text' to be visible | Result text appears on the page | Result text is visible | PASS |
| 6 | Assert that the result text equals 'Test Passed' | Text content is 'Test Passed' | result.text == 'Test Passed' | PASS |
| 7 | Quit the remote WebDriver session | Browser session closed on remote node | - | PASS |