Selenium 4 keeps opening a default Firefox instance

33 views Asked by At

I am currently learning Selenium 4 on Python 3.12 to automate web tasks and whenever I run my code, it will open another Firefox instance with the default settings of everything.

I want to make my program open in my default Firefox profile if the browser isn't running or open it in a new tab if Firefox is already running, then close the tab once it is done.

from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))

# code stuffs here

I suspect it's opening a new profile but it doesn't seem to generate a new profile every time I run it. I also deleted all redundant and unused profiles, but it will still open a defaulted Firefox instance.

0

There are 0 answers