Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
like image 428
Artūras Stonys Avatar asked Mar 24 '26 16:03

Artūras Stonys


1 Answers

Update. Better way to open Firefox in debugging mode (defaults to port 6000):

firefox.exe --start-debugger-server --profile C:\FirefoxTEMP
like image 64
Artūras Stonys Avatar answered Mar 26 '26 06:03

Artūras Stonys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!