Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Firefox binary ignoring some settings in profile #2061

Closed
lukeis opened this issue Mar 2, 2016 · 30 comments
Closed

Firefox binary ignoring some settings in profile #2061

lukeis opened this issue Mar 2, 2016 · 30 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 2061

Using Mac OSX 10.6, Firefox 5.01, python bindings.
Not sure about selenium python bindings version, can't find it but I downloaded it
this week.

I set up a profile to use a proxy.
    profile = webdriver.FirefoxProfile()
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.http", "localhost")
    profile.set_preference("network.proxy.http_port", 9638)
    profile.set_preference("network.proxy.no_proxies_on", "")
    profile.update_preferences()
    driver = webdriver.Firefox(firefox_profile=profile)

The call to webdriver.Firefox fails with an error like this:
WebDriverException: Can't load the profile. Profile Dir : /var/folders/CW/CWhi40qkHJaRdfl7JNBS1++++TI/-Tmp-/tmpbs7gZo

The exception is being triggered because _wait_until_connectable is timing out in firefox_binary.

This is happening because the browser's proxy has not been configured right. Using
about:config, the Firefox browser tells me that I've change network.proxy.type and
network.proxy.http_port but not the other 2 necessary settings.

Why is the Firefox binary ignoring the other 2 settings?

Reported by rwillmer on 2011-07-15 16:28:51

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Python bindings v2.1.0 installed from pip

Reported by rwillmer on 2011-07-21 08:07:20

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I think I know what the issue is, I will sort this before the release of 2.2

Reported by david.burns@theautomatedtester.co.uk on 2011-07-22 20:17:11

  • Status changed: Accepted
  • Labels added: Lang-Python

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Thanks, let me know if I can help with testing the fix before the release.

Reported by rwillmer on 2011-07-23 10:43:22

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

i found one part of the issue but this has opened another can of worms. Unfortunately
it won't be this release but there will be another release in a week.

Reported by david.burns@theautomatedtester.co.uk on 2011-07-25 16:37:59

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I think the problem is how it saves profile items that need to be loaded by firefox
as a string.

profile.set_preference("network.proxy.http", "localhost") will save the preference
value as localhost.

What worked for me was changing it to:

profile.set_preference("network.proxy.http", '"localhost"'), so it saves it as "localhost".

Reported by mikeraytrack on 2011-07-27 00:58:39

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Mikerayt: where did you set the preference of the profile?

Reported by skuli.arnlaugsson on 2011-07-28 15:06:01

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm having problems with selenium 2.2 and ff5.01 trying to set
    profile.set_preference('signon.autologin.proxy', "true")

This is a boolean property, not string or integer. I've tried 'true', "true" '"true"',
"'true'", and True but nothing works.

Reported by random35743373 on 2011-07-28 15:22:57

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

where did you set the preference of the profile?:

p = webdriver.FirefoxProfile()
p.set_preference(...,...)
...

b = webdriver.Firefox(p)

----

to fix "profile.set_preference('signon.autologin.proxy', "true")" try this:
profile.set_preference('signon.autologin.proxy', 1)

Reported by mikeraytrack on 2011-07-28 15:49:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'd already tried that but forgot to mention it.

For another boolean property I tried each of these, one at a time.

profile = webdriver.FirefoxProfile()
profile.set_preference('general.warnOnAboutConfig', '"false"')
profile.set_preference('general.warnOnAboutConfig', "'false'")
profile.set_preference('general.warnOnAboutConfig', 'false')
profile.set_preference('general.warnOnAboutConfig', "false")
profile.set_preference('general.warnOnAboutConfig', False)
profile.set_preference('general.warnOnAboutConfig', 0)
# to the value of a pref that is already set correctly
profile.set_preference('general.warnOnAboutConfig', profile.default_preferences['browser.tabs.warnOnOpen'])

profile.update_preferences()
br = webdriver.Firefox(profile)

Nothing works :(

Reported by random35743373 on 2011-07-28 15:57:48

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Hi guys,

I have added changes to this in r13122 that should solve it.

Reported by david.burns@theautomatedtester.co.uk on 2011-07-28 16:55:45

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

David,

That does indeed seem to fix the problem I reported. Thanks.

Rachel

Reported by rwillmer on 2011-08-01 19:10:12

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

as of comment 11 this is closed

Reported by david.burns@theautomatedtester.co.uk on 2011-08-01 19:20:47

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I have the same problem,
but above patch doesn't work.
well - the problem is independent of the used FirefoxProfile (own or default)

moreover I had situation when "WebDriverException: Can't load the profile. Profile
Dir"
appeared after the application works fine long time (Firefox invoked and connectable)

I tested it on many computers in others networks and with selenium 2.1 - 2.4
with many possible configuration of FirefoxProfile

I have connection without proxy.

Reported by slawek@nect.pl on 2011-08-12 08:32:06

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

i have this problem when invoking a test script via ssh but not when physically sitting
at a machine and invoking same script on a terminal line.  Is there some kind of X
dependency at work here?

Reported by mcdanieldave on 2011-08-24 19:34:30

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

just fyi for those that have my issue above, using xvfb and export DISPLAY=":99" &&
in front of my script command gets me expected results

Reported by mcdanieldave on 2011-08-24 19:59:09

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Fyi, we ran into a similar issue with profiles... this maybe helpful for others as we
just put a profile called selenium.profile in the calling path for our tests and our
binary is in a different location:

import selenium.webdriver.firefox.webdriver as fwb
from selenium.common.exceptions import TimeoutException

driver_dir = os.path.dirname(os.path.abspath(file))
profile_dir = os.path.join(driver_dir, 'selenium.profile')

Create a new instance of the Firefox driver

binary = fwb.FirefoxBinary(firefox_path='/usr/bin/firefox')
profile = fwb.FirefoxProfile(profile_directory=profile_dir)
driver = fwb.WebDriver(firefox_profile=profile, firefox_binary=binary)


Reported by `aquaperf` on 2011-08-25 21:55:34

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm having the same issue on Linux with python webdriver v2.5.0 (and python 2.7.2):

>>> ff_profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile()
>>> driver = webdriver.Firefox(ff_profile)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "selenium/webdriver/firefox/webdriver.py", line 46, in __init__
    self.binary, timeout),
  File "selenium/webdriver/firefox/extension_connection.py", line 46, in __init__
    self.binary.launch_browser(self.profile)
  File "selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
    self._wait_until_connectable()
  File "selenium/webdriver/firefox/firefox_binary.py", line 87, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile Dir : %s" % self.profile.path)
selenium.common.exceptions.WebDriverException: Message: "Can't load the profile. Profile
Dir : /tmp/tmps5ErDu"


Funny is that firefox starts well and works ok

Reported by f_ii@post.cz on 2011-08-29 14:13:01

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Let me more precisely describe the case from comment 18 and workaround.

My machine has multiple firefox browsers installed (old 2.x in std path and new in
custom path), when creating webdriver.Firefox() instance new FF window opens and above
WebDriverException is thrown.

When I specify the browser location below listed way, no exception is thrown:

import selenium.webdriver.firefox.webdriver as fwb
ff_bin = fwb.FirefoxBinary(firefox_path='/qbin/firefox/firefox')
ff_profile = fwb.FirefoxProfile()
driver = fwb.WebDriver(firefox_profile=ff_profile, firefox_binary=ff_bin)
driver.get('http://www.seznam.cz')

Therefore it seems that if multiple firefox browsers are installed then FirefoxBinary
full path is necessary (which is sort of expected)



Reported by f_ii@post.cz on 2011-08-29 15:05:43

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Answering comment #9:

If you're using selenium into python, try setting preferences this way:

profile.set_preference('general.warnOnAboutConfig', False)

i.e., using builtin python booleans True and False.

Reported by ciberglo on 2011-09-10 07:41:04

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

FWIW, I was getting this error with FF 3.6.x on Mac OS X 10.6, but went away when I
upgraded to FF 7.x.

Reported by gregoryba on 2011-09-29 19:06:37

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am getting this error only when I execute via mod_wsgi
If I ran this from same virtualenv but directly from terminal (not via mod_wsgi) it
works just fine.
the code is extremely simple:

From selenium import webdriver
wd = webdriver.Firefox() # << this will give you Can't load the profile error.

I am running FF 7.X, Selenium version 2.5 with Python 2.7
Upgraded to 2.7 didn't resolve problem.

I have tried the followings
1. Patch provided by David (comment 10) already on my selenium
2. Setting up profile profile_directory advice given by Comment 17 gave me same error
with different path
    >> Can't load the profile. Profile Dir: /tmp/tmp1Kcie8/webdriver-py-profilecopy
3. Advice by Ciber at comment 20 didn't work either. Basically same error..

Any advice would be appreciated

Reported by NaokoReeves on 2011-10-08 17:30:51

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Hi the problem is still there :(

d:\______selenium>ff2.py
Traceback (most recent call last):
  File "D:\______selenium\ff2.py", line 2, in <module>
    wd = webdriver.Firefox() # << this will give you Can't load the profile error.
  File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line
45, i
n __init__
    self.binary, timeout),
  File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\extension_connection.py",
 line 46, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py",
line
41, in launch_browser
    self._wait_until_connectable()
  File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py",
line
73, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile Dir : %s" % self.profile.pat
h)
selenium.common.exceptions.WebDriverException: Message: "Can't load the profile. Profile
D
ir : c:\\users\\vzak\\appdata\\local\\temp\\tmpcevqwi"

Reported by zakvladimir on 2011-11-23 20:00:48

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Got the same error. Selenium 2.14.0. Firefox 9, OSX 10.6. I suspect this is related
FF9 beta (upgrade).

Reported by miohtama on 2011-12-03 00:04:49

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Same error. Scripts works alright for a while, then can't load profile anymore.
Python 2.6, Selenium 2.15.0, Iceweasel 3.5.16, Debian 2.6.32-5-amd64

Reported by juego.video on 2011-12-14 10:49:38

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

 :(

i can not start the drive to load a page, and a min ago, it worked just fine

Reported by pengphy on 2011-12-31 08:48:46

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Has this been resolved?  Started happening to me today.

Reported by August.Heim on 2012-04-06 13:40:15

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I got the same issue and fixed it by updating the selenium python package:
> sudo pip install -U selenium

Reported by charles.braquet on 2012-05-07 20:05:56

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I have found the same issue when I run my test on CentOS

What I do is run tests thru Xvfb

Xvfb :99 -fp /usr/share/X11/fonts/misc -screen 0 1280x1024x24 &
export DISPLAY=:99 
DISPLAY=:99 python26

and unfortunately all these options doesn't work

-------------------
from selenium import webdriver
d = webdriver.Firefox()

-------------------

from selenium import webdriver
ff_profile = webdriver.firefox.firefox_profile.FirefoxProfile()
driver = webdriver.Firefox(ff_profile)

------------------

import selenium.webdriver.firefox.webdriver as fwb
from selenium.common.exceptions import TimeoutException
import os

driver_dir = os.path.dirname(os.path.abspath('/home/mykhpoli/file'))
profile_dir = os.path.join(driver_dir, 'selenium.profile')

# Create a new instance of the Firefox driver
binary = fwb.FirefoxBinary(firefox_path='/usr/bin/firefox')
profile = fwb.FirefoxProfile(profile_directory=profile_dir)
driver = fwb.WebDriver(firefox_profile=profile, firefox_binary=binary)

--------------------

import selenium.webdriver.firefox.webdriver as fwb
ff_bin = fwb.FirefoxBinary(firefox_path='/usr/bin/firefox')
ff_profile = fwb.FirefoxProfile()
driver = fwb.WebDriver(firefox_profile=ff_profile, firefox_binary=ff_bin)
driver.get('http://www.seznam.cz')

-----

my configuration

python: 2.6
selenium==2.21.3
centos: 5.4

Reported by polusok on 2012-05-11 10:58:56

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

exception I got:


>>> driver = fwb.WebDriver(firefox_profile=ff_profile, firefox_binary=ff_bin)
FreeFontPath: FPE "/usr/share/X11/fonts/misc" refcount is 2, should be 1; fixing.
FreeFontPath: FPE "/usr/share/X11/fonts/misc" refcount is 2, should be 1; fixing.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/webdriver.py",
line 51, in __init__
    self.binary, timeout),
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/extension_connection.py",
line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py",
line 43, in launch_browser
    self._start_from_profile_path(self.profile.path)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py",
line 65, in _start_from_profile_path
    env=self._firefox_env).wait()
  File "/usr/lib64/python2.6/subprocess.py", line 1170, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/usr/lib64/python2.6/subprocess.py", line 465, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt
>>> FreeFontPath: FPE "/usr/share/X11/fonts/misc" refcount is 2, should be 1; fixing.

Reported by polusok on 2012-05-11 11:00:08

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 18:13:16

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 2, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant