简体   繁体   English

Selenium firefox 配置文件不再工作

[英]Selenium firefox profile not working anymore

So I was happily using selenium together with Firefox and it seems that my firefox profile wouldn't load anymore some morning.所以我很高兴将 selenium 和 Firefox 一起使用,似乎我的 firefox 配置文件在某个早上不再加载。 It is driving me nuts to be honest.老实说,这让我发疯。 Whatever I try, the profile that is being used keeps being in the temp folder.无论我尝试什么,正在使用的配置文件一直在临时文件夹中。

The following snippet is what I am doing以下片段是我正在做的

def getFireFoxBrowserWithUserFolder(folder) :

options = webdriver.FirefoxOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_argument("user-data-dir=" + folder)
firefox = webdriver.FirefoxProfile(folder)
return webdriver.Firefox(options=options, executable_path=r'/home/bunsen/seleniumDriver/geckodriver', firefox_profile=firefox)

This worked up until very recent.这一直持续到最近。 I got the newest version of the geckodriver(0.31.0), running it all on Debian stable, so my FF version is 91.10.0ESR (that is also what I see in the selenium browser).我得到了最新版本的 geckodriver(0.31.0),在 Debian 稳定运行,所以我的 FF 版本是 91.10.0ESR(这也是我在 selenium 浏览器中看到的)。

I am at a loss at this point, anyone with the same problem?我现在很茫然,有人有同样的问题吗?

first install webdriver_manager:首先安装 webdriver_manager:

pip install webdriver-manager

then:然后:

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver import Firefox

def getFireFoxBrowserWithUserFolder(folder) :
    options = webdriver.FirefoxOptions()
    options.add_argument("--disable-blink-features=AutomationControlled")
    options.add_argument("user-data-dir=" + folder)
    # here you can choose driver version 
    driver =  Firefox(options = options, executable_path=GeckoDriverManager(version="2.26").install())

    return driver

More informations about webdriver manager here .有关 webdriver manager 的更多信息,请点击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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