Test Overview
This test connects to a Selenium Grid hub and runs a simple browser test on a node. It verifies that the page title is correct, confirming the grid setup works.
This test connects to a Selenium Grid hub and runs a simple browser test on a node. It verifies that the page title is correct, confirming the grid setup works.
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities # Connect to Selenium Grid Hub hub_url = "http://localhost:4444/wd/hub" # Use Chrome browser on the node capabilities = DesiredCapabilities.CHROME.copy() # Create remote WebDriver session driver = webdriver.Remote(command_executor=hub_url, desired_capabilities=capabilities) try: # Open example page driver.get("https://example.com") # Assert page title assert driver.title == "Example Domain", f"Expected title 'Example Domain' but got '{driver.title}'" 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 | Selenium Grid hub is running and has at least one Chrome node registered | - | PASS |
| 2 | Browser on node opens and navigates to https://example.com | Browser window is open on the node, loading the example.com page | - | PASS |
| 3 | Check that the page title is exactly 'Example Domain' | Page is fully loaded with title 'Example Domain' | Assert driver.title == 'Example Domain' | PASS |
| 4 | Close the browser and end the session | Browser window is closed, session terminated | - | PASS |