Edge configuration in Selenium Python - Build an Automation Script
from selenium import webdriver from selenium.webdriver.edge.service import Service from selenium.webdriver.edge.options import Options from selenium.webdriver.common.by import By import time # Configure Edge options options = Options() options.add_argument("--start-maximized") options.add_argument("--disable-notifications") # Initialize Edge driver with options service = Service() # Assumes msedgedriver is in PATH try: driver = webdriver.Edge(service=service, options=options) driver.get("https://example.com") # Verify page title assert driver.title == "Example Domain", f"Expected title 'Example Domain' but got '{driver.title}'" finally: driver.quit()
This script starts by importing necessary Selenium classes for Edge browser automation.
We create an Options object to add arguments that start the browser maximized and disable notifications, matching the manual test case requirements.
The Service object is created without arguments assuming the Edge WebDriver executable is in the system PATH.
We then create the Edge driver with these options and navigate to 'https://example.com'.
An assertion checks that the page title exactly matches 'Example Domain'. If not, it raises an error with a clear message.
Finally, the driver.quit() call in the finally block ensures the browser closes even if the assertion fails or an error occurs.
Now add data-driven testing to open three different URLs with the same Edge configuration and verify their titles.