Joff
Joff

Reputation: 12177

selenium testing with django gives 'NoneType' object has no attribute 'path'

I cannot see what is making this error happen because it does not give me more information. The tests pass, but they print this message to the console. I will post my files below.

tests.py:

class MainAppTests(LiveServerTestCase):
    """Testing the interactions on the main page"""

    def setUp(self):
        """Opening the browser"""
        selenium_logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
        # Only display possible problems
        selenium_logger.setLevel(logging.ERROR)
        self.browser = webdriver.Firefox()
        self.user = make_user()

    def tearDown(self):
        """Closing the browser"""
        self.browser.quit()

    def test_homepage(self):
        """Testing that everything work"""
        self.browser.get(self.live_server_url)
        self.assertIn("Site", self.browser.title)

views.py:

def home(request):
    """View for displaying the home page"""
    if request.user.is_authenticated():
        # Pulling and ordering by the 'full_name' field, shows users what is available
        active_languages = Language.objects.filter(active=True).order_by('full_name')
        context = {'active_languages': active_languages}
        return render(request, 'main/home_loggedin.html', context)
    return render(request, 'main/home_loggedout.html', status=302)

Upvotes: 1

Views: 469

Answers (1)

Penkey Suresh
Penkey Suresh

Reputation: 5974

It's not you, it's selenium... :) Your code is correct.

This is a recent issue with selenium, happening with python client during self.browser.quit().

Updating selenium should do the trick. Although due to the recent nature of the bug (reported and fixed on 21th Oct), at the moment, the fix is not yet incorporated the recent version of selenium. It should be be fixed on versions above 3.0.1

Upvotes: 2

Related Questions