Complete the code to create a Firefox WebDriver instance.
from selenium import webdriver browser = webdriver.Firefox([1])
The service parameter is used to specify the geckodriver executable service in Selenium 4+. Passing service=None uses the default service.
Complete the code to set Firefox to run in headless mode.
from selenium.webdriver.firefox.options import Options options = Options() options.[1] = True browser = webdriver.Firefox(options=options)
Setting options.headless = True enables headless mode in Firefox.
Fix the error in the code to set a custom Firefox profile path.
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile profile = FirefoxProfile('[1]') browser = webdriver.Firefox(firefox_profile=profile)
The FirefoxProfile constructor requires the full absolute path to the profile folder. The Windows path with double backslashes is correct.
Fill both blanks to set a Firefox preference and start the browser with it.
from selenium.webdriver.firefox.options import Options from selenium.webdriver.firefox.firefox_profile import FirefoxProfile profile = FirefoxProfile() profile.set_preference('[1]', [2]) browser = webdriver.Firefox(firefox_profile=profile)
Setting javascript.enabled to True enables JavaScript in Firefox.
Fill all three blanks to create a Firefox WebDriver with headless mode and a custom profile path.
from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.firefox.firefox_profile import FirefoxProfile options = Options() options.[1] = True profile = FirefoxProfile('[2]') browser = webdriver.Firefox(options=options, firefox_profile=profile, service=[3])
Set options.headless = True to run Firefox headless, provide the full profile path, and pass service=None to use default driver service.