简体   繁体   English

Python Firefox Selenium 负载配置文件

[英]Python Firefox Selenium Load Profile

I tried many combinations of Geckodrive,Selenium and Python but i could not achieved to load Firefox profile what i need.It loads the default profile.我尝试了 Geckodrive、Selenium 和 Python 的许多组合,但我无法加载我需要的 Firefox 配置文件。它加载了默认配置文件。 The lastest code is below and I opened an issue on github Selenium page but there is still no solution.There are some solutions about Java but I am not able to bind it in Python.A temp file created on temp folder which includes profile data and cookies.That mean selenium does not use any profile's cookies and other configurations最新代码如下,我在 github Selenium 页面上打开了一个问题,但仍然没有解决方案。有一些关于 Java 的解决方案,但我无法在 Python 中绑定它。在临时文件夹上创建的临时文件包含配置文件数据和cookies。这意味着 selenium 不使用任何配置文件的 cookie 和其他配置

Any solutions will be apprecited.任何解决方案都会受到赞赏。

Geckodrive version:0.23 Selenium 3.14 Python 3.7 Firefox 61 Geckodrive 版本:0.23 Selenium 3.14 Python 3.7 Firefox 61

from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.support.ui import WebDriverWait

fp = FirefoxProfile('C:\\Users\\<USER>\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\ji8rbij6.test')
fp.update_preferences()
browser = webdriver.Firefox(firefox_profile=fp) 

Thanks in advance提前致谢

PS. PS。 I tried this code block in 3 different computer because of being able to have a problem on my own computer由于能够在我自己的计算机上出现问题,我在 3 台不同的计算机上尝试了此代码块

This exact setup works as expected for me (windows10) and I'm able to load custom firefox profiles.这个确切的设置对我来说可以正常工作(windows10),我可以加载自定义的 firefox 配置文件。 Firefox: 88.0.1 Geckodriver: 0.30.0 ( geckodriver releases Python: 3.8.10 robotframework-selenium2library: 3.0.0 robotframework-seleniumlibrary: 6.0.0 Firefox:88.0.1 Geckodriver:0.30.0( geckodriver 发布Python:3.8.10 robotframework-selenium2library:3.0.0 robotframework-seleniumlibrary:6.0.0

import SeleniumLibrary
from selenium import webdriver
from robot.libraries.BuiltIn import BuiltIn
def create_profile(self)
    fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.manager.showWhenStarting", False)
    fp.set_preference("browser.download.panel.shown", False)
    fp.set_preference("browser.download.dir","**provide_download_dir_here**")
    fp.set_preference("browser.helperApps.neverAsk.openFile", 
    "application/zip,application/octet-stream, application/x-zip-compressed, 
    multipart/x-zip,image/jpeg,application/xml,application/pdf,text/plain,text/csv, 
    */*")
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", 
    "application/zip,application/octet-stream, application/x-zip-compressed, 
    multipart/x-zip,image/jpeg,application/xml,application/pdf,text/plain,text/csv, 
    */*")
    fp.update_preferences()
    return fp.path
# Add the following code where you open the browser
ff = self.create_profile()   
BuiltIn().get_library_instance("SeleniumLibrary").open_browser("https://your_url","F    irefox",ff_profile_dir=ff)

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

相关问题 在python selenium中加载Firefox的配置文件 - Load a profile of Firefox in python selenium 如何使用 Python Selenium 加载 Firefox 配置文件? - How to load firefox profile with Python Selenium? 无法使用硒,python加载firefox配置文件 - cannot load firefox profile with selenium, python python硒选择随机Firefox配置文件 - python selenium choose random firefox profile 在python中使用默认的firefox配置文件和selenium webdriver - Using the default firefox profile with selenium webdriver in python Python Selenium设置Firefox配置文件的路径(ubuntu) - Python Selenium setting path to firefox profile (ubuntu) Python Selenium 在 Z1D41C853AF58D3A7AE54990CE294 中设置 firefox 配置文件的路径 - Python Selenium setting path to firefox profile in ubuntu Python:Selenium Firefox Webdriver失败并显示错误:&#39;无法加载配置文件... WARN addons.xpi ...“ - Python: Selenium Firefox Webdriver failing with error: 'Can't load the profile…WARN addons.xpi…" 如何将 cookies 保存到 Selenium Python 中的 Firefox 配置文件中,然后在接下来的 session 中再次加载它们? - How can I save cookies to my Firefox Profile in Selenium Python and load them in again next session? Python / Selenium / Firefox:无法使用指定的配置文件路径启动 firefox - Python / Selenium / Firefox: Can't start firefox with specified profile path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM