Test Overview
This test opens a Chrome browser with specific options to disable notifications and run in headless mode. It verifies the browser title to confirm the page loaded correctly.
This test opens a Chrome browser with specific options to disable notifications and run in headless mode. It verifies the browser title to confirm the page loaded correctly.
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By import unittest class TestBrowserOptions(unittest.TestCase): def setUp(self): chrome_options = Options() chrome_options.add_argument('--disable-notifications') chrome_options.add_argument('--headless') self.driver = webdriver.Chrome(service=Service(), options=chrome_options) def test_google_title(self): self.driver.get('https://www.google.com') title = self.driver.title self.assertEqual(title, 'Google') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome browser is launched with options --disable-notifications and --headless | Chrome browser runs in headless mode with notifications disabled | - | PASS |
| 2 | Browser navigates to https://www.google.com | Google homepage is loaded in the headless browser | - | PASS |
| 3 | Retrieve the page title | Page title is 'Google' | Check if page title equals 'Google' | PASS |
| 4 | Close the browser | Browser session ends | - | PASS |