Bird
0
0

Identify the error in this Selenium Python code for downloading a CSV file:

medium📝 Debug Q14 of 15
Selenium Python - Advanced Patterns
Identify the error in this Selenium Python code for downloading a CSV file:
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.dir', '/tmp/downloads')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')
driver = webdriver.Firefox(profile)
driver.get('http://example.com/data.csv')
AMissing options parameter in webdriver.Firefox()
BDownload folder path must be absolute
CIncorrect argument name; should be firefox_profile=profile
DWrong MIME type for CSV files
Step-by-Step Solution
Solution:
  1. Step 1: Check webdriver.Firefox() usage

    Firefox expects profile passed as firefox_profile=profile, not just profile.
  2. Step 2: Confirm other settings

    MIME type 'text/csv' and folder path are correct; no options parameter needed here.
  3. Final Answer:

    Incorrect argument name; should be firefox_profile=profile -> Option C
  4. Quick Check:

    Use firefox_profile=profile argument = D [OK]
Quick Trick: Pass profile with firefox_profile=profile keyword [OK]
Common Mistakes:
  • Passing profile as positional argument
  • Changing MIME type unnecessarily
  • Using relative folder path

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes