Boa
Boa

Reputation: 2677

selenium opening the wrong Firefox-based browser

I recently installed the Waterfox browser, which is essentially a faster, 64-bit Firefox, and which shares Firefox's user data folder. Since, then, invoking Firefox with selenium, as in the following line, invokes the Waterfox browser:

from selenium import webdriver
browser = webdriver.Firefox()

After a few moments, the program crashes, producing the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 77, in __init__
    self.binary, timeout),
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\extension_conne
ction.py", line 49, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\firefox_binary.
py", line 68, in launch_browser
    self._wait_until_connectable()
  File "C:\Python\lib\site-packages\selenium\webdriver\firefox\firefox_binary.
py", line 103, 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, ch
eck it for details.

Is there a way to explicitly tell selenium to invoke the actual Firefox browser (I'm not inclined to tinker with the system registry unless necessary), instead of opening Waterfox?

Upvotes: 3

Views: 1109

Answers (2)

rubo77
rubo77

Reputation: 20817

I use this to invoke firefox:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
options = Options()
options.headless = False
SITE = "http://localhost/something_I_want_to_convert_with_hi-resolution.html"
DPI = 2.5
profile = webdriver.FirefoxProfile()
profile.set_preference("layout.css.devPixelsPerPx", str(DPI))
driver = webdriver.Firefox(options=options, firefox_profile=profile)

driver.get(SITE)
...

Upvotes: 0

Breaks Software
Breaks Software

Reputation: 1761

Yes, try this:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('path/to/binary')
driver = webdriver.Firefox(firefox_binary=binary)

From this question.

Upvotes: 2

Related Questions