in this code, i think only --headless is working properly
i tried with -p or --profile "path to firefox profile", none of this is working
def initialize_web_driver():
try:
firefox_options = webdriver.FirefoxOptions()
firefox_options.add_argument('--headless')
firefox_options.add_argument("-p GPTT")
firefox_options.set_preference("browser.shell.checkDefaultBrowser", False)
driver = webdriver.Firefox(options=firefox_options)
driver.set_window_size(1920, 1080)
return driver
except Exception as e:
print(f"Error initializing WebDriver: {str(e)}")
return None
When you using firefox_options.add_argument, you must set profile path with new firefox_options.add_argument line, if you use profile path same line with -profile -P,etc. it will not working.
firefox_options = webdriver.FirefoxOptions()
firefox_options.add_argument('--headless')
firefox_options.add_argument("-profile")
firefox_options.add_argument("C:\\Users\\User2\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\qgrlmh39.GPTT")
driver = webdriver.Firefox(options=firefox_options)
driver.set_window_size(1920, 1080)