Test Overview
This test opens a Firefox browser with a custom profile that disables images to speed up loading. It verifies the browser starts with the profile applied by checking the page title.
This test opens a Firefox browser with a custom profile that disables images to speed up loading. It verifies the browser starts with the profile applied by checking the page title.
from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.by import By import unittest class TestFirefoxProfile(unittest.TestCase): def setUp(self): profile = webdriver.FirefoxProfile() # Disable images to speed up loading profile.set_preference('permissions.default.image', 2) profile.update_preferences() options = Options() self.driver = webdriver.Firefox(firefox_profile=profile, options=options) def test_page_title(self): self.driver.get('https://example.com') title = self.driver.title self.assertEqual(title, 'Example Domain') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Create FirefoxProfile and set preference to disable images | FirefoxProfile object configured with images disabled | - | PASS |
| 2 | Launch Firefox browser with the custom profile | Firefox browser opens with images disabled | - | PASS |
| 3 | Navigate to https://example.com | Browser loads example.com page without images | - | PASS |
| 4 | Get page title and assert it equals 'Example Domain' | Page title is 'Example Domain' | assertEqual(title, 'Example Domain') | PASS |
| 5 | Close the browser | Browser closed | - | PASS |