TJB
TJB

Reputation: 3836

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
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import unittest

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

class NewVisitorTest(unittest.TestCase):  

    def setUp(self):  
        self.browser = webdriver.Firefox(capabilities=caps)

    def tearDown(self):  
        self.browser.quit()

    def test_can_start_a_list_and_retrieve_it_later(self):  
        self.browser.get('http://localhost:8000')

        self.assertIn('To-Do', self.browser.title)  

if __name__ == '__main__':  
    unittest.main(warnings='ignore') 

Stack Trace

Creating test database for alias 'default'...
EException ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x103f652b0>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 151, in __del__
    self.stop()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 123, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

======================================================================
ERROR: test_can_start_a_list_and_retrieve_it_later (functional_tests.NewVisitorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/timothybaney/Treehouse/TDD/superlists/functional_tests.py", line 13, in setUp
    self.browser = webdriver.Firefox(capabilities=caps)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 82, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 62, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
NotADirectoryError: [Errno 20] Not a directory

----------------------------------------------------------------------
Ran 1 test in 0.012s

FAILED (errors=1)
Destroying test database for alias 'default'...

Upvotes: 3

Views: 3076

Answers (1)

Yacdaniel Hurtado
Yacdaniel Hurtado

Reputation: 56

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

Upvotes: 3

Related Questions