[Django]-Django application selenium testing no static files

45👍

Instead of using LiveServerTestCase from django.test you can use
StaticLiveServerTestCase from django.contrib.staticfiles.testing.

Notice not just the different class-name, but also the different module-name:

from django.test import LiveServerTestCase
#     ^-- vs --v
from django.contrib.staticfiles.testing import StaticLiveServerTestCase

9👍

Ok I found the solution. First I had to add in setting

STATIC_ROOT = 'my static dir'

then:

./manage.py collectstatic
👤tstr

3👍

I had a similar issue and none of the answers above helped me.

For anyone using Whitenoise as a static file server, it turns out you may have to change the value of the STATICFILES_STORAGE setting in your app, from:

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

To:

STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"

That fixed my problem. See this page for more information.

Leave a comment