1

It seems that loading the profile keeps failing even though I am specifying the path location of the profile it seems to be loading from a different path (according to the traceback). Am I missing something here?

CODE

from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile

profile = FirefoxProfile('/Users/path/Library/Application Support/Firefox/Profiles/9s60syvx.default')
browser = webdriver.Firefox(firefox_profile=profile)
<snip>

TRACKBACK

File "/Users/path/Python/Projects/test/login.py", line 12, in <module>
  browser = webdriver.Firefox(firefox_profile=profile)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
  self.binary, timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
  self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
  self._wait_until_connectable(timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 108, in _wait_until_connectable
  % (self.profile.path))

selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/dy/yl4zdm8n5j184hhfq_2j3bdh0000gn/T/tmpY3UPuy/webdriver-py-profilecopy If you specified a log_file in the FirefoxBinary constructor, check it for details.

Firefox Version = 48.0.2

selenium Version = 2.53.6

OS Version = OSX 10.11.6

iNoob
  • 1,375
  • 3
  • 19
  • 47
  • I Think this the compatibility issue between `selenium` and `Firefox`, you should try using `geckodriver`, follow [this link for more info](http://stackoverflow.com/questions/38676719/fail-to-launch-mozilla-with-selenium) – Saurabh Gaur Sep 12 '16 at 11:07
  • I have attempted to use the geckodriver (aka wires) however I may not be doing it correctly. I will make another attempt and let you know how I get on. – iNoob Sep 12 '16 at 11:30
  • I get `selenium.common.exceptions.WebDriverException: Message: 'wires' executable needs to be in PATH.` Even though I have added the path to `PATH$`. I have renamed the binary to 'wires'. I have pointed the caps binary to the newly downloaded gecko (aka wires). – iNoob Sep 12 '16 at 11:37
  • Yes, now its better, you need to put `geckodriver` executable location into System `PATH` variable before running it..:) – Saurabh Gaur Sep 12 '16 at 11:39
  • yes as mentioned I have already done that, still get the error – iNoob Sep 12 '16 at 11:40
  • Follow this link https://github.com/mozilla/geckodriver/issues/90 – Saurabh Gaur Sep 12 '16 at 11:41
  • `firefox_capabilities['binary']` points to the `firefox` binary itself, not `geckodriver`. Instead, add the directory where `geckodriver` lives to your path: `os.environ["PATH"] += "path/to/geckodriver"`.. – Saurabh Gaur Sep 12 '16 at 11:44
  • I added the dir to PATH directly via `sudo nano /etc/paths` as it was not persistent via `export` but still get the error (I having been following https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver, again I did all of this already before making this post) Thanks for the help so far – iNoob Sep 12 '16 at 11:50
  • Are you mention executable as well with the path?? – Saurabh Gaur Sep 12 '16 at 11:52
  • I can confirm it is in the path using `wires` on the term command line, it runs as expected. Ill attempt to add via python as you suggested and see what happens – iNoob Sep 12 '16 at 11:53
  • Am doing `caps["marionette"] = True` `caps["binary"] = "~/Applications/Firefox.app"` `browser = webdriver.Firefox(capabilities=caps)` – iNoob Sep 12 '16 at 11:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/123160/discussion-between-inoob-and-saurabh-gaur). – iNoob Sep 12 '16 at 11:55

1 Answers1

0

The simplest way is to move the geckodriver binary to the directory you already have in the PATH:

mv geckodriver /usr/local/bin

If you want to have it at a different location, please note that the PATH has to point to the directory that contains the geckodriver and not to the binary itself. To add the the custom directory to the PATH you should do it in the code because you probably don't want to have it system wide.

os.environ["PATH"] += os.pathsep + 'path/to/dir/containing/geckodriver/'

After that, do the usual stuff you want.

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/usr/bin/firefox'
profile = FirefoxProfile('/path/to/your/profile')
browser = webdriver.Firefox(capabilities=firefox_capabilities
                            firefox_profile=profile)
dsalaj
  • 2,857
  • 4
  • 34
  • 43
  • thanks, however i moved to chromedriver in the end and it works perfectly. So I wont be testing your solution, however if it gets vote ups by other with the issue im happy to accept it. – iNoob Mar 24 '17 at 14:23