Bird
0
0

Identify the error in the following Firefox configuration code and select the fix:

medium📝 Debug Q14 of 15
Selenium Python - Cross-Browser Testing
Identify the error in the following Firefox configuration code and select the fix:
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless(True)
browser = Firefox(options=options)
browser.quit()
AChange options.headless(True) to options.headless = True
BImport FirefoxOptions instead of Options
CAdd browser.quit() before creating browser
DRemove options argument from Firefox() constructor
Step-by-Step Solution
Solution:
  1. Step 1: Identify incorrect method call

    The line options.headless(True) incorrectly calls headless as a method, but it is a property to set.
  2. Step 2: Correct syntax for setting headless

    It should be options.headless = True to enable headless mode properly.
  3. Final Answer:

    Change options.headless(True) to options.headless = True -> Option A
  4. Quick Check:

    Set headless as property, not method [OK]
Quick Trick: Use assignment (=), not function call, for headless [OK]
Common Mistakes:
  • Calling headless as a method
  • Confusing Options class import
  • Misplacing browser.quit() call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes