Bird
0
0

What will be the output of the following code snippet?

medium📝 Predict Output Q13 of 15
Selenium Python - Cross-Browser Testing
What will be the output of the following code snippet?
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True
browser = Firefox(options=options)
print(browser.capabilities['moz:headless'])
browser.quit()
AKeyError exception
BTrue
CNone
DFalse
Step-by-Step Solution
Solution:
  1. Step 1: Understand headless option effect on capabilities

    Setting options.headless = True tells Firefox to run without UI, reflected in capabilities under key 'moz:headless' as True.
  2. Step 2: Check the print statement output

    The print statement accesses browser.capabilities['moz:headless'], which will be True because headless mode is enabled.
  3. Final Answer:

    True -> Option B
  4. Quick Check:

    Headless mode enabled means moz:headless = True [OK]
Quick Trick: Check capabilities key 'moz:headless' for headless status [OK]
Common Mistakes:
  • Assuming 'moz:headless' key is missing
  • Expecting False when headless is set True
  • Confusing capabilities with options

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes