Bird
0
0

You want to disable Firefox notifications during Selenium tests to avoid pop-ups. Which code snippet correctly sets this preference using FirefoxOptions?

hard📝 Application Q15 of 15
Selenium Python - Cross-Browser Testing
You want to disable Firefox notifications during Selenium tests to avoid pop-ups. Which code snippet correctly sets this preference using FirefoxOptions?
Aoptions = FirefoxOptions() options.set_capability('notifications', False)
Boptions = FirefoxOptions() options.add_argument('--disable-notifications')
Coptions = FirefoxOptions() options.headless = False options.disable_notifications = True
Doptions = FirefoxOptions() options.set_preference('dom.webnotifications.enabled', False)
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct method to set Firefox preferences

    Use options.set_preference() to set Firefox-specific preferences like disabling notifications.
  2. Step 2: Verify preference key and value

    The key 'dom.webnotifications.enabled' controls notifications; setting it to False disables them.
  3. Final Answer:

    options = FirefoxOptions() options.set_preference('dom.webnotifications.enabled', False) -> Option D
  4. Quick Check:

    Use set_preference with correct key to disable notifications [OK]
Quick Trick: Use set_preference('dom.webnotifications.enabled', False) [OK]
Common Mistakes:
  • Using add_argument for Firefox preferences
  • Setting non-existent properties like disable_notifications
  • Confusing capabilities with preferences

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes