简体   繁体   中英

How to connect Selenium to existing Firefox browser? (Python)

Does anyone knows how to connect existing Firefox browser with Selenium? I tried Chrome way - no luck.

Launches Firefox in debugging mode:

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

The code I wrote in 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.exe --remote-debugging-port=9223 --user-data-dir="C:\selenum\ChromeProfile"

Update. Better way to open Firefox in debugging mode:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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