python - 如何将 Selenium 连接到现有的 Firefox 浏览器? (Python)

标签 python selenium firefox

有谁知道如何将现有的 Firefox 浏览器与 Selenium 连接起来?我尝试了 Chrome 方式 - 不走运。

在 Debug模式下启动 Firefox:

start firefox.exe --marionette -foreground -no-remote -profile C:\FirefoxTEMP

我用Python写的代码:

from selenium import webdriver
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9224")
drivePath = r'C:\\geckodriver.exe'
driver = webdriver.Firefox(options= options, executable_path = drivePath)

我猜是启动 Debug模式的问题。在 Chrome 上,我可以使用命令和端口来完成:

chrome.exe --remote-debugging-port=9223 --user-data-dir="C:\selenum\ChromeProfile"

最佳答案

更新。在 Debug模式下打开 Firefox 的更好方法(默认端口 6000):

firefox.exe --start-debugger-server --profile C:\FirefoxTEMP

关于python - 如何将 Selenium 连接到现有的 Firefox 浏览器? (Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66154886/

相关文章:

python - statsmodel 中的 MNLogit 返回 nan

python - 消除网络的内部环路

java - 如何使用Java测试Selenium2中的下载文件,然后检查下载文件的格式?

java - 运行平均种子时 jasmine_node 失败

Javascript 多行字符串替换为多行字符串

python - 如何使用元组填充数据框?

python - 除第一列外的所有行的平均值

python - XPath:通过*纯*文本查找 HTML 元素

javascript - 对于 Firefox 中的 pdf 文件,文件 API 返回 "invalid/octet-stream"

amazon-web-services - Chrome/Firefox 浏览器因 AWS Sagemaker 和 Jupyter 而崩溃 - 如何记录/调试?