title: How to set preferences for FireFox in Robot Framework
body: <p>I'm trying to write a test case in robot framework to download an excel file automatically from a web-site. I want to set preferences for my browser using robot scripts to download files automatically in my desired destination directory without asking me! </p>
  
  <p>I have tried <a href="https://stackoverflow.com/questions/28553322/set-auto-download-preference-profile-using-selenium2library?answertab=oldest#tab-top">this solution</a>; but it didn't work. </p>
  
  <p>I also tried to set an existing firefox profile as <a href="https://stackoverflow.com/questions/16462894/robot-framework-run-firefox-with-system-proxy?answertab=oldest#tab-top">this</a> says which works fine, but I want to be capable of automatically adjusting preferences. </p>
  
  <p>Any idea?</p>
  
  <p>As @Sachin said I wrote a python script to set preferences for FireFox as well:</p>
  
  <pre><code>from selenium import webdriver
  class WebElement(object):
      @staticmethod
      def create_ff_profile(path):
          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.neverAsk.saveToDisk", 'application/csv')
          fp.update_preferences()
          return fp
  </code></pre>
  
  <p>And used it in Robot scenario:</p>
  
  <pre><code>*** Settings ***
  Library                 Selenium2Library
  Library                 Selenium2LibraryExtensions
  Library                 OperatingSystem
  Library                 ../../../Libraries/WebElement.py
  *** Variables ***
  ${profileAddress}       C:\\Users\\user\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\VdtJKHal.default
  ${destinationUrl}       http://www.principlesofeconometrics.com/excel.htm
  ${browserType}          firefox
  ${downloadDir}          C:\\Users\\user\\Desktop
  ${acceptedTypes}        text/csv/xls/xlsx
  ${itemXpath}            //*[text()="airline"]
  *** Test Cases ***
  My Test Method
      log to console  Going to open browser with custome firefox profile!
      ${profile} =    create_ff_profile   ${downloadDir}
      Open Browser    ${destinationUrl}   ${browserType}  ff_profile_dir=${profile}
      Maximize Browser Window
      Click Element   xpath=${itemXpath}
      Sleep   10
      Close Browser
  </code></pre>
  
  <p>But I got error <code>TypeError: coercing to Unicode: need string or buffer, FirefoxProfile found</code> in method <code>_make_browser</code> of library <code>_browsermanagement.py</code>.</p>
  
  <p>I edited the code and removed <code>return fp</code> and then changed the Robot test case like this:</p>
  
  <p>And used it in Robot scenario:</p>
  
  <pre><code>*** Test Cases ***
  My Test Method
      log to console  Going to open browser with custome firefox profile!
      create_ff_profile   ${downloadDir}
      Open Browser    ${destinationUrl}   ${browserType}  ff_profile_dir=${profileAddress}
      Maximize Browser Window
      Click Element   xpath=${itemXpath}
      Sleep   10
      Close Browser
  </code></pre>
  
  <p>It removed the exception and set my preferences as well, but I still need to pass the profile address. </p>