Unable to invoke firefox headless

前端 未结 1 1190
小蘑菇
小蘑菇 2021-01-06 07:11

I would like to know why i\'m getting the following error message and how can i fix it:

Traceback (most recent call last): File \"teste.py\", line

相关标签:
1条回答
  • 2021-01-06 07:52

    I solved my problem. Here the code:

    from selenium import webdriver
    from selenium.webdriver.firefox.options import Options as FirefoxOptions
    from selenium.webdriver.chrome.options import Options as ChromeOptions
    
    def connectChrome():
        options = ChromeOptions()
        options.add_argument("--headless")
        chromeDriverPath = "/usr/bin/chromedriver"
        driver = webdriver.Chrome(chromeDriverPath, chrome_options=options)
        print("Chrome Headless Browser Invoked")
        return driver
    
    def connectFirefox():
        options = FirefoxOptions()
        options.add_argument("--headless")
        driver = webdriver.Firefox(firefox_options=options)
        print("Firefox Headless Browser Invoked")
        return driver
    
    def main():
        #driver = connectChrome()
        driver = connectFirefox()
        driver.get("https://www.archlinux.org/")
        print("Headless Browser closing")
        driver.quit()
    #------------------------------------------------------------------------#
    main()
    
    0 讨论(0)
提交回复
热议问题