Test Overview
This test opens Microsoft Edge browser using Selenium WebDriver, navigates to a sample website, finds a button by its ID, clicks it, and verifies the page title changes as expected.
This test opens Microsoft Edge browser using Selenium WebDriver, navigates to a sample website, finds a button by its ID, clicks it, and verifies the page title changes as expected.
from selenium import webdriver from selenium.webdriver.edge.service import Service 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 TestEdgeConfig(unittest.TestCase): def setUp(self): service = Service(executable_path='msedgedriver') options = webdriver.EdgeOptions() options.use_chromium = True self.driver = webdriver.Edge(service=service, options=options) self.driver.maximize_window() def test_click_button_and_check_title(self): self.driver.get('https://example.com') wait = WebDriverWait(self.driver, 10) button = wait.until(EC.element_to_be_clickable((By.ID, 'start-button'))) button.click() wait.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 - unittest framework initializes | No browser open yet | — | PASS |
| 2 | Edge WebDriver service and options configured, Edge browser opens maximized | Edge browser window is open and maximized | — | PASS |
| 3 | Browser navigates to 'https://example.com' | Page 'Example Domain' loaded in Edge browser | — | PASS |
| 4 | Waits until button with ID 'start-button' is clickable | Button is visible and enabled on the page | Element located and clickable | PASS |
| 5 | Clicks the 'start-button' | Button click triggers page title change | — | PASS |
| 6 | Waits until page title is 'Example Domain - Started' | Page title updated to 'Example Domain - Started' | Title matches expected value | PASS |
| 7 | Asserts that the page title equals 'Example Domain - Started' | Page title is 'Example Domain - Started' | assertEqual passes | PASS |
| 8 | Test ends, browser quits | Edge browser closed | — | PASS |
Options() in Edge configuration with Selenium?Options()Options() is used to configure browser settings such as running in headless mode or setting window size.Service()Service() is used to specify the driver location, not browser settings.add_argument().webdriver.Edge() using the options parameter.from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
options = Options()
options.add_argument('--window-size=800,600')
service = Service('path/to/msedgedriver')
driver = webdriver.Edge(service=service, options=options)
print(driver.execute_script('return window.innerWidth + "," + window.innerHeight'))
driver.quit()--window-size=800,600.from selenium import webdriver
from selenium.webdriver.edge.options import Options
options = Options()
options.add_argument('--headless')
driver = webdriver.Edge(options=options, executable_path='msedgedriver.exe')executable_path parameter is deprecated in recent Selenium versions for Edge.Service object with the driver path and pass it via the service parameter.add_argument() to add both '--headless' and '--user-agent=MyCustomAgent' correctly.Service object with the driver path and pass it to webdriver.Edge() via the service parameter.executable_path and wrong attribute names. from selenium import webdriver
service = Service('C:/drivers/msedgedriver.exe')
driver = webdriver.Edge(service=service)
driver.add_argument('--headless')
driver.add_argument('user-agent=MyCustomAgent') tries to add arguments to driver object which is invalid. from selenium import webdriver
options = Options()
options.add_argument('--headless')
options.add_argument('--user-agent=MyCustomAgent')
driver = webdriver.Edge(options=options) misses driver path specification.Pass the test and this pattern moves unknown