更新时间:2022-03-12 22:42:35
使用 Selenium 3.4.x、Python 3.6.1 以及 geckodriver v0.16.1 &Mozilla Firefox 53.0,您可以通过以下步骤使用现有的 Firefox 配置文件:
Using Selenium 3.4.x, Python 3.6.1 along with geckodriver v0.16.1 & Mozilla Firefox 53.0, you can use the existing Firefox profile through the following steps:
"debanjan"
位于 C:\Users\AtechM_03\AppData\Roaming\Mozilla\Firefox\Profiles
,名称为 w8iy627a.debanjan.webdriver
时指定Firefox Profile 目录的绝对路径.这是在我的 Windows 机器上打开现有 Firefox Profile 'debanjan'
的工作代码:
"debanjan"
was located at C:\Users\AtechM_03\AppData\Roaming\Mozilla\Firefox\Profiles
by the name w8iy627a.debanjan
. webdriver
. Here is the working code which opens an existing Firefox Profile 'debanjan'
on my Windows machine:
需要注意的是,当前的 Selenium-Python 绑定对于 geckodriver 是不稳定的,并且看起来是特定于架构的.您可以找到 github 讨论 和 在这里合并.因此,您可能还需要在初始化 webdriver
It is to be noted that the current Selenium-Python binding is unstable with geckodriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary while initializing the webdriver
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
profile = webdriver.FirefoxProfile('C:\Users\AtechM_03\AppData\Roaming\Mozilla\Firefox\Profiles\w8iy627a.debanjan')
binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
url = 'https://www.paininneck.co.uk'
driver.get(url)