Test Overview
This test opens Chrome with a custom configuration to disable notifications and verifies the browser starts with these settings applied.
This test opens Chrome with a custom configuration to disable notifications and verifies the browser starts with these settings applied.
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options import unittest class TestChromeConfig(unittest.TestCase): def setUp(self): chrome_options = Options() chrome_options.add_argument('--disable-notifications') self.driver = webdriver.Chrome(service=Service(), options=chrome_options) def test_chrome_starts_with_disabled_notifications(self): self.driver.get('https://www.example.com') title = self.driver.title self.assertIn('Example Domain', title) def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and ChromeOptions is configured to disable notifications | ChromeOptions object created with '--disable-notifications' argument | — | PASS |
| 2 | Chrome browser opens with the configured options | Chrome browser window opens without notification popups | — | PASS |
| 3 | Browser navigates to 'https://www.example.com' | Example Domain page loads in browser | — | PASS |
| 4 | Test checks if page title contains 'Example Domain' | Page title is 'Example Domain' | assertIn('Example Domain', title) | PASS |
| 5 | Test ends and browser closes | Chrome browser window closes | — | PASS |
Options() in Selenium with Chrome?Options() class in Selenium is used to set Chrome browser configurations like headless mode, window size, or disabling notifications before launching the browser.from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--incognito')
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('disable-notifications')
driver = webdriver.Chrome(options=options)Pass the test and this pattern moves unknown