Reputation: 165
My python script has the following code:
firefox_profile = webdriver.FirefoxProfile()
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
When I execute the script from bash it works, but if I call the script from a PHP file, with the following command:
shell_exec("python path_to_the_script");
I receive the exception:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /tmp/tmp7Ob0z6/webdriver-py-profilecopy If you specified a log_file in the FirefoxBinary constructor, check it for details.
I've also tried to set the profile manually, like this:
firefox_profile = webdriver.FirefoxProfile(profile_directory='path_to_the_profile_dir')
But nothing changed, while if I set the profile directory path like this:
firefox_profile = webdriver.FirefoxProfile(profile_directory='path_to_the_profile_dir')
firefox_profile.profile_dir = 'path_to_the_profile_dir'
The exception error changes to this:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: path_to_the_profile_dir If you specified a log_file in the FirefoxBinary constructor, check it for details.
I've set the permissions to 777 for all the involved directories, and also tried to override the FirefoxBinary.launch_browser
function so that it uses a greater timeout value, but id did not work.
I'm using Python 2.7, Selenium 2.53.6 and Firefox 46.0.1
Firefox is working in headless mode, through Xvfb and pyvirtualdisplay.
Upvotes: 1
Views: 2860
Reputation: 11
If that didn't fix your issue check your firefox profile name
like this
fp = webdriver.FirefoxProfile('/home/YOUR_USERNAME/.mozilla/firefox/YOUR_PROFILE_NAME.default')
driver = webdriver.Firefox(firefox_profile=fp)
To find your firefox profile name open your file browser and enable "show hidden files" go to "Home/.mozilla/firefox" and you'll see your firefox profile folder.
I hope that solved your issue
Upvotes: 0
Reputation: 11
This happens because you have updated firefox to a version that's no longer supported by selenium.
So to fix this you have 2 options.
If you have ubuntu follow this fix below:
1. Update selenium with "sudo pip install -U selenium"
2. Download the geckodriver from github -->
Gecko Github Link
3. Extract the tar.gz folder and move the gecko executable to /usr/local/bin
4. Now open your terminal and enter this command: export PATH=$PATH:/usr/local/bin/geckodriver
That should fix the issue... atleast it worked for me.
My Source: StackOverflow - Geckodriver
Upvotes: 1