title: Setting selenium to use custom profile, but it keeps opening with default
body: <p>I am trying to use python and selenium to automate some tasks in firefox. When I download a file, that pop up comes up asking if you want to open or save, and a check box for do this every time with this kind of file. I have found that check box does not work unless you install the add on Web Page Fixer. I have that installed normally, but when I use python + selenium it uses a profile with no add ons. </p>
  
  <p>The internet has instructed me to create another profile by closing Firefox, opening /Applications/Utilities, then typing the command:</p>
  
  <pre><code>/Applications/Firefox.app/Contents/MacOS/firefox-bin -p
  </code></pre>
  
  <p>I then create a new profile that I will use with selenium. I set the name and change the folder name. The profile name is "PTI_Auto_Profile". The folder path displays as follows:</p>
  
  <pre><code>/users/User/Library/Application Support/Firefox/Profiles/Selenium/
  </code></pre>
  
  <p>When I am done. I click 'Start Firefox', and the following error appears on my terminal screen. </p>
  
  <pre><code>2013-04-11 11:57:30.422 firefox-bin[2248:707] invalid drawable
  conf-room:~ User$ 2013-04-11 11:58:00.350 firefox-bin[2251:303] invalid drawable
  </code></pre>
  
  <p>I've tried the following to no success.</p>
  
  <pre><code>profile = webdriver.FirefoxProfile(os.path.expanduser("~/Library/Application Support/Firefox/Profiles/Selenium/"))
  driver = webdriver.Firefox(firefox_profile=profile) 
  </code></pre>
  
  <p>No error, default user.</p>
  
  <pre><code>profile = webdriver.FirefoxProfile(os.path.expanduser("~/Library/Application Support/Firefox/Profiles/Selenium/"))
  driver = webdriver.Firefox(profile) 
  </code></pre>
  
  <p>No error, default user.</p>
  
  <pre><code>fp = webdriver.FirefoxProfile()
  fp.set_preference("browser.download.folderList",2)
  fp.set_preference("browser.download.manager.showWhenStarting",False)
  fp.set_preference("browser.download.dir",getcwd())
  fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv/xls")
  
  driver = webdriver.Firefox(firefox_profile=fp)
  </code></pre>
  
  <p>Error:
      fp.set_preference("browser.download.dir",getcwd())
      NameError: name 'getcwd' is not defined</p>
  
  <p>Any ideas on what I am doing wrong? Thank you!</p>
  
  <p>p.s. I am using mac os x 10.8.2, python 2.7, firefox 20</p>
  
  <p><strong>SOLUTION PROVIDED BY Corey Goldberg.</strong> This should work for all excel versions. </p>
  
  <pre><code>import os
  from selenium import webdriver
  profile = webdriver.FirefoxProfile()
  profile.set_preference('browser.download.folderList', 2)
  profile.set_preference('browser.download.manager.showWhenStarting', False)
  profile.set_preference('browser.download.dir', os.getcwd())
  profile.set_preference('browser.helperApps.neverAsk.saveToDisk', ('application/vnd.ms-excel'))
  driver = webdriver.Firefox(profile)
  </code></pre>