Shantanu Bedajna
Shantanu Bedajna

Reputation: 581

Firefox Python selenium not going headless

I am trying to make firefox headless and doing exactly as shown in the documentation.

This shouldn't be doing what it is supposed to the firefox window is appearing even when I am adding the headless argument

cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False

options = webdriver.FirefoxOptions()
options.add_argument('-headless')
driver = webdriver.Firefox(firefox_options=options, capabilities=cap)

this should not open the firefox window but it opening the window enter image description here I have never had this kind of problem with chrome and chromedriver

I have downloaded the 64-bit geckodriver binary and it is in PATH what am I doing wrong here?

Upvotes: 1

Views: 778

Answers (2)

Moshe Slavin
Moshe Slavin

Reputation: 5214

You need to use Options() not webdriver.FirefoxOptions():

from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument('--headless')

Hope this helps you!

Upvotes: 1

Jitendra Banshpal
Jitendra Banshpal

Reputation: 555

Try following code block:

from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True

Upvotes: 1

Related Questions