Python selenium打开错误的基于Firefox的浏览器

Python selenium打开错误的基于Firefox的浏览器,python,firefox,selenium,Python,Firefox,Selenium,我最近安装了Waterbox浏览器,它本质上是一个更快的64位Firefox,它共享Firefox的用户数据文件夹。因此,使用selenium调用Firefox(如下所示)会调用Waterbox浏览器: from selenium import webdriver browser = webdriver.Firefox() 几分钟后,程序崩溃,产生以下回溯: Traceback (most recent call last): File "<stdin>", line 1, i

我最近安装了Waterbox浏览器,它本质上是一个更快的64位Firefox,它共享Firefox的用户数据文件夹。因此,使用selenium调用Firefox(如下所示)会调用Waterbox浏览器:

from selenium import webdriver
browser = webdriver.Firefox()
几分钟后,程序崩溃,产生以下回溯:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 77, in __init__
    self.binary, timeout),
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\extension_conne
ction.py", line 49, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\firefox_binary.
py", line 68, in launch_browser
    self._wait_until_connectable()
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\firefox_binary.
py", line 103, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile.
Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, ch
eck it for details.
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Python\lib\site packages\selenium\webdriver\firefox\webdriver.py”,
第77行,in_uuuinit__
self.binary,超时),
文件“C:\Python\lib\site packages\selenium\webdriver\firefox\extension\u conne
“action.py”,第49行,in__init__
self.binary.launch_浏览器(self.profile)
文件“C:\Python\lib\site packages\selenium\webdriver\firefox\firefox\u binary。
py”,第68行,在启动浏览器中
self.\u等待\u直到\u可连接()
文件“C:\Python\lib\site packages\selenium\webdriver\firefox\firefox\u binary。
py”,第103行,在可连接之前等待
引发WebDriverException(“无法加载配置文件。配置文件”
selenium.common.exceptions.WebDriverException:消息:无法加载配置文件。
配置文件目录:%s如果您在FirefoxBinary构造函数ch中指定了日志文件
查看详细信息。
有没有办法明确告诉selenium调用实际的Firefox浏览器(除非必要,否则我不想修改系统注册表),而不是打开Waterbox?

是的,尝试以下方法:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('path/to/binary')
driver = webdriver.Firefox(firefox_binary=binary)

From.

我使用它来调用firefox:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
options = Options()
options.headless = False
SITE = "http://localhost/something_I_want_to_convert_with_hi-resolution.html"
DPI = 2.5
profile = webdriver.FirefoxProfile()
profile.set_preference("layout.css.devPixelsPerPx", str(DPI))
driver = webdriver.Firefox(options=options, firefox_profile=profile)

driver.get(SITE)
...

我尝试在python脚本中使用Waterbox,使用
binary=FirefoxBinary('/usr/bin/waterbox classic')
,这确实启动了Waterbox,但它没有加载页面,如果我将路径设置为标准firefox,它通常会加载。我还需要更改什么,才能从firefox切换到Waterbox?