简体   繁体   English

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

[英]How to connect Selenium to existing Firefox browser? (Python)

Does anyone knows how to connect existing Firefox browser with Selenium?有谁知道如何将现有的 Firefox 浏览器与 Selenium 连接? I tried Chrome way - no luck.我尝试了 Chrome 的方式 - 没有运气。

Launches Firefox in debugging mode:在调试模式下启动 Firefox:

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

The code I wrote in Python:我在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)

I guess it's a problem with launching debugging mode.我猜这是启动调试模式的问题。 On Chrome I can do it with a command and a port:在 Chrome 上,我可以使用命令和端口来完成:

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

Update.更新。 Better way to open Firefox in debugging mode:在调试模式下打开 Firefox 的更好方法:

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

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM