0
0
Selenium Pythontesting~10 mins

Chrome configuration in Selenium Python - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test opens Chrome with a custom configuration to disable notifications and verifies the browser starts with these settings applied.

Test Code - unittest
Selenium Python
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()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts and ChromeOptions is configured to disable notificationsChromeOptions object created with '--disable-notifications' argument-PASS
2Chrome browser opens with the configured optionsChrome browser window opens without notification popups-PASS
3Browser navigates to 'https://www.example.com'Example Domain page loads in browser-PASS
4Test checks if page title contains 'Example Domain'Page title is 'Example Domain'assertIn('Example Domain', title)PASS
5Test ends and browser closesChrome browser window closes-PASS
Failure Scenario
Failing Condition: Chrome fails to start with the '--disable-notifications' option or page title does not match
Execution Trace Quiz - 3 Questions
Test your understanding
What does the '--disable-notifications' argument do in ChromeOptions?
AEnables notifications for all websites
BDisables JavaScript on the page
CPrevents Chrome from showing notification popups
DRuns Chrome in headless mode
Key Result
Always configure browser options explicitly to control browser behavior during tests, such as disabling notifications to avoid unexpected popups that can interfere with test execution.