简体   繁体   中英

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 在此处输入图片说明 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?

Try following code block:

from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM