Firefox cannot use custom profile

Hi,

I am trying to launch firefox on windows 10 with custom made firefox profile in order to enable automatic file download but geckodriver keeps using the default one.
I have made a kw for creating the custom profile:

def create_firefox_profile(self, path):
fp = selenium_driver.FirefoxProfile()
fp.set_preference(“browser.download.folderList”, 2)
fp.set_preference(“browser.download.manager.showWhenStarting”, False)
robot_logger.console(“Download path: {}”.format(path))
fp.set_preference(“browser.download.dir”, path)
fp.set_preference(“browser.helperApps.neverAsk.saveToDisk”, “application/csv, text/csv, text/plain, application/pdf, text/pdf”)
fp.update_preferences()
robot_logger.console(“firefox profile path: {}”.format(fp.path))
return fp.path

Inside the robot test case I use the kws below:

${download_path} =    Create Firefox Profile    ${OUTPUT DIR}
    ${host_os} =    Check Host OS
    Log    ${host_os}
    ${fp_path} =    Run Keyword If    '${host_os}' == 'win32'    Modify FirefoxProfile Windows Path    
   ${download_path}
    Log    ${fp_path}
    Open Browser    ${webapp.ff_url}    ff_profile_dir=${fp_path}

And the kw Modify FirefoxProfile Windows Path for handling the backslashes on windows platforms as explained in the lib’s documentation :

Modify FirefoxProfile Windows Path
    [Arguments]    ${fp_path}=${EMPTY}
    Log    ${fp_path}
    ${fp_path} =    Replace String Using Regexp    ${fp_path}    \\\\    \\\\\\\\
    Log    ${fp_path}
    [Return]    ${fp_path}

Versions used:
SeleniumLibrary 5.1.3
selenium: 3.141.0
geckodriver: 26.0 and now I switched to latest 30.0
firefox: 91 ESR and previously latest 94.0

From the geckodriver logs I always see the output as below:

1638876114279	geckodriver	INFO	Listening on 127.0.0.1:52364
**1638876117356	mozrunner::runner	INFO	Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-no-remote" "-profile" "C:\\Users\\manos\\AppData\\Local\\Temp\\rust_mozprofile1aBtGJ"**
1638876117805	Marionette	INFO	Marionette enabled
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at C:\\Users\\manos\\AppData\\Local\\Temp\\rust_mozprofile1aBtGJ\\search.json.mozlz4", (void 0)))
1638876120053	Marionette	INFO	Listening on port 52376
1638876120535	RemoteAgent	WARN	TLS certificate errors will be ignored for this session

I got same issue right now. Custom ff profile is created and saved in TEMP but I suppose it’s not used when called with Open Browser keyword.

Did you find the solution?

No sure, if it still helps you, but I used this python function:

def disable_download_dialog(path):
    from selenium import webdriver
    fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.manager.showWhenStarting", False)
    fp.set_preference("browser.download.dir", path)
    fp.set_preference("browser.helperApps.alwaysAsk.force", False)
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk",'application/pdf')
    fp.set_preference("pdfjs.disabled", True)
    fp.update_preferences()
    return fp.path

it helped me with the issue

2 Likes