Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Selenium Python - Cross-Browser Testing
Identify the error in this code snippet:
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = Firefox(options=options, firefox_profile='myprofile')
Aheadless attribute cannot be set to True
B'myprofile' should be a FirefoxProfile object, not a string
COptions cannot be passed to Firefox constructor
DFirefox driver does not support headless mode
Step-by-Step Solution
Solution:
  1. Step 1: Check firefox_profile parameter type

    firefox_profile expects a FirefoxProfile object, not a string.
  2. Step 2: Identify the error cause

    Passing 'myprofile' string causes a type error at runtime.
  3. Final Answer:

    'myprofile' should be a FirefoxProfile object, not a string -> Option B
  4. Quick Check:

    firefox_profile requires FirefoxProfile object [OK]
Quick Trick: Pass FirefoxProfile object, not string, to firefox_profile [OK]
Common Mistakes:
  • Thinking headless=True is invalid
  • Believing options cannot be passed
  • Assuming Firefox lacks headless support

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes