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

2024-10-05 10:37:12 发布

您现在位置:Python中文网/ 问答频道 /正文

有人知道如何将现有的Firefox浏览器与Selenium连接起来吗?我试着用Chrome的方式-没有运气

以调试模式启动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)

我想这是启动调试模式的问题。在Chrome上,我可以通过命令和端口来实现:

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

Tags: fromimportremoteselenium浏览器chromefirefoxexe

热门问题