Python Selenium - DeprecationWarning: firefox_profile has been deprecated, please use an Options object

Python Selenium - DeprecationWarning: firefox_profile has been deprecated, please use an Options object

Při použití Python Selenium s konstrukcí níže může nastat chyba DeprecationWarning: firefox_profile has been deprecated, please use an Options object

profile     = webdriver.FirefoxProfile('/home/ccc/.mozilla/firefox/l14zaesm.default-release')
driver = webdriver.Firefox(profile) 
driver.get("https://www.up4.cz")

Řešení

Je potřeba importovat

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options

a upravit konstrukci takto:

    options = Options() 
    options.set_preference('profile', profile_path) 
    service = Service('/usr/bin/geckodriver') 
    driver = Firefox(service=service, options=options) 
    driver.get("https://www.up4.cz")
Jak se ti článek líbil?

Komentáře (0)

Přidat komentář