简体   繁体   中英

Selenium Firefox : TypeError: __init__() got an unexpected keyword argument 'options'

from selenium.webdriver.chrome.options import Options
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.firefox.options import Options as Firefox_Options
from selenium import webdriver
from selenium.common.exceptions import WebDriverException

firefox_options = Firefox_Options()

if headless_browser:
    firefox_options.add_argument('-headless')

if browser_profile_path is not None:
    firefox_profile = webdriver.FirefoxProfile(
        browser_profile_path)
else:
    firefox_profile = webdriver.FirefoxProfile()

# set English language
firefox_profile.set_preference('intl.accept_languages', 'en')

if disable_image_load:
    # permissions.default.image = 2: Disable images load,
    # this setting can improve pageload & save bandwidth
    firefox_profile.set_preference('permissions.default.image', 2)

if proxy_address and proxy_port:
    firefox_profile.set_preference('network.proxy.type', 1)
    firefox_profile.set_preference('network.proxy.http',
                                   proxy_address)
    firefox_profile.set_preference('network.proxy.http_port',
                                   proxy_port)
    firefox_profile.set_preference('network.proxy.ssl',
                                   proxy_address)
    firefox_profile.set_preference('network.proxy.ssl_port',
                                   proxy_port)

browser = webdriver.Firefox(firefox_profile=firefox_profile,
                            options=firefox_options)

TypeError: init () got an unexpected keyword argument 'options'

Selenium package version == 3.141.0

The same code was working fine till 1 day back. I suspect some other dependant package upgrade might have screwed it up.

Apparently this is what fixed it:

sudo chown -R $USER /usr/local/lib/python3.6
sudo chown -R $USER /Users/ishandutta2007/.pyenv
pip uninstall urllib3
pip uninstall selenium
pip install --upgrade git+https://github.com/socialbotspy/SocialCommons.git
pip install -r requirements.txt 

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