0
0
Selenium Pythontesting~10 mins

Firefox configuration in Selenium Python - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test opens Firefox with a custom configuration to disable notifications and verifies the browser launches correctly with the set preferences.

Test Code - unittest
Selenium Python
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.by import By
import unittest

class TestFirefoxConfig(unittest.TestCase):
    def setUp(self):
        options = Options()
        options.set_preference("dom.webnotifications.enabled", False)
        self.driver = webdriver.Firefox(options=options)

    def test_firefox_launch_with_config(self):
        self.driver.get("https://www.example.com")
        element = self.driver.find_element(By.TAG_NAME, "h1")
        self.assertEqual(element.text, "Example Domain")

    def tearDown(self):
        self.driver.quit()

if __name__ == "__main__":
    unittest.main()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts and Firefox options are set to disable notificationsFirefox options object created with 'dom.webnotifications.enabled' set to False-PASS
2Firefox browser is launched with the configured optionsFirefox browser window opens without notification prompts-PASS
3Browser navigates to 'https://www.example.com'Example Domain page is loaded and visible-PASS
4Find the <h1> element on the page<h1> element with text 'Example Domain' is presentCheck that the <h1> text equals 'Example Domain'PASS
5Close the browser and end the testFirefox browser window closes-PASS
Failure Scenario
Failing Condition: Firefox browser fails to launch with the specified options or element not found
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test configure Firefox to do before launching?
ADisable web notifications
BEnable pop-up windows
CSet browser to private mode
DChange the homepage to example.com
Key Result
Always configure browser preferences explicitly in tests to avoid unexpected pop-ups or notifications that can interfere with automation.