Timothy Joseph Baney Timothy Joseph Baney - 3 months ago 75
Python Question

Selenium can't open Firefox 48.0.1

I am starting to learn how to become a better test driven developer when creating web applications in Django. I am trying to use Selenium to open a browser, but I am getting an error.

selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/xn/bvyw0fm97j1_flsyggj0xn9r0000gp/T/tmptoxt890d If you specified a log_file in the FirefoxBinary constructor, check it for details.


I read that by "Installing the FF extension "Disable Add-on Compatibility Checks" skips this and everything is fine." selenium.common.exceptions.WebDriverException: Message: Can't load the profile. I did this, but It is still not working. I used Python2.7 and Python3.5 with Selenium version 2.53.6.

Python file

from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://localhost:8000')

assert 'Django' in browser.title

Answer

That error is because you are using FF 48. For FF>=47 FirefoxDriver stop working. You must use the new MarionetteDriver

Set up this:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True

browser = webdriver.Firefox(capabilities=caps)
browser.get('http://localhost:8000')

assert 'Django' in browser.title