Why wouldn't Selenium be able to load a firefox profile?
Question: The following code:

    
    
    from selenium import webdriver
    from selenium.common.exceptions import TimeoutException
    from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
    from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
    import os.path
    import os
    FIREFOX_PATH = os.path.join("C:", 
                                "FirefoxPortable", "FirefoxPortable.exe")
    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    binary = FirefoxBinary(FIREFOX_PATH)
    driver = webdriver.Firefox(firefox_binary=binary)
    
    # go to the google home page
    driver.get("http://www.google.com")
    

Fails with a complaint that the profile can't be loaded:

    
    
    $ python test_selenium.py
    Traceback (most recent call last):
      File "test_selenium.py", line 17, in <module>
        driver = webdriver.Firefox(firefox_profile=profile,firefox_binary=binary)
      File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
        self.binary, timeout),
      File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
        self.binary.launch_browser(self.profile)
      File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 66, in launch_browser
        self._wait_until_connectable()
      File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 105, in _wait_until_connectable
        raise WebDriverException("Can't load the profile. Profile "
    selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
    

Any thoughts what is going on?

I confess I care not a whit about profiles (and have only the vaguest sense
what they are) - I just want a basic browser loaded so I can automate some web
scraping.

Many thanks! /YGA


Answer: As per [this](http://stackoverflow.com/questions/2422798/python-os-path-join-
on-windows) question, specifying the path as below worked. This searches for
the `FirefoxPortable` folder in `D:/`.

    
    
    FIREFOX_PATH = os.path.join("D:/", "FirefoxPortable", "FirefoxPortable.exe")
    

Also, the below code is working fine. I removed the `import os` line as it was
redundant.

    
    
    from selenium import webdriver
    from selenium.common.exceptions import TimeoutException
    from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
    from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
    import os.path
    
    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    
    FIREFOX_PATH = os.path.join("D:/", "FirefoxPortable", "FirefoxPortable.exe")
    binary = FirefoxBinary(FIREFOX_PATH)
    driver = webdriver.Firefox(firefox_binary=binary)
    
    # go to the google home page
    driver.get("http://www.google.com")
    driver.quit()
    

