SeleniumLibrary: ff_profile_dir does nothing

I’m trying to use a new Firefox profile so I can control download directory location.

I’ve created Firefox profile and set directory.

In my Robot test I define the ff_profile_dir:

   Open Browser
    ...  url=${START_URL}
    ...  browser=${BROWSER}
    ...  ff_profile_dir=C:/Users/mydir/AppData/Local/Mozilla/Firefox/Profiles/robot

Run test - the file is downloaded but not in the correct directory defined in the profile.

Environment

  • Windows 10
  • geckodriver 0.23.0
  • robotframework==3.0.4
  • robotframework-seleniumlibrary==3.2.0
  • selenium==3.141.0
  • Firefox Developer Edition 64
  • Firefox 63.0.3

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted comments

I think I found the issue. I had opened the Selenium profile in firefox browser manually that i was working on. Since that profile was already in use, the same profile coudln’t be opened twice using Selenium and RobotFramework.

IT WORKS! I could have sworn I tried browser.download.folderList = 2 but that may have been before I reinstalled my browsers.

Thank you so much!

Replying to both the comments : @jimpriest
Not exactly, i created a Selenium profile manually using firefox Manager and i use that profile to run automation which is free of all plugins.

And then using the Open Browser Keyword specified above i provide the path of the Selenium profile i created manually.

I tried the same thing in chrome, even that is also not opening the default ff_profile_dir i provide.

Also if i run this chunk of code , it does open the right profile i need

from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

options = Options() options.add_argument(“-profile”) options.add_argument(“C:\Users\userid\AppData\Roaming\Mozilla\Firefox\Default”) firefox_capabilities = DesiredCapabilities.FIREFOX firefox_capabilities[‘marionette’] = True driver = webdriver.Firefox(capabilities=firefox_capabilities, firefox_options=options)

@bjneuhaus
it’s my account name on my machine, not a variable, did not specify the name. I have minimum 2 spaces between the keyword and argument. Profile path exists

I did modify your code and I did get the automatic download working with this code:

from selenium import webdriver


def create_profile():
    fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.manager.showWhenStarting", False)
    fp.set_preference("browser.download.dir", "D:\\tmp\\foobar")
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/java-archive, application/x-msexcel,application/excel,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/vnd.microsoft.portable-executable")
    fp.update_preferences()
    return fp.path

And by running this test:

*** Settings ***
Library           SeleniumLibrary
Library           ./foo.py

*** Test Cases ***
Test 1
    ${ff} =    Create Profile
    Open Browser    https://www.seleniumhq.org/download/    ff    ff_profile_dir=${ff}
    Sleep    3
    Click Element    //p[text()='Download version ']/a
   # Keyword where which pols the correct file is present.  

There are two differences in the create_profile method:

  1. fp.set_preference("browser.download.folderList", 1) -> fp.set_preference("browser.download.folderList", 2)
  2. The MIME types are wider than in your example

The MIME types are based on this blog post. But because SeleniumLibrary and also Firefox seems to be working correctly, I am closing the issue.