I have an issue with Lettuce + Django + Splinter. Lettuce does not seem to be able to pick up changes to the database. Below, create_user
and create_post
generate and save a user and a few post models. However when splinter opens the browser - there seem to be no posts on the page, when I try to access the list view.
I am running lettuce via python manage.py harvest --test-server
.
@step(ur'visit "(.*)" url')
def visit_url(step, name):
[create_post().save() for i in xrange(2)]
world.browser = Browser()
world.browser.visit(django_url(url))
The URL I am trying to access is a Post list view, and same construction works perfectly from django's test framework, so I know it is not an issue with django or splinter.
The solution was to set a LETTUCE_TEST_SERVER
value to a test runner based on Django LiveServerTestCase
. Thus, I had to add a line to settings.py
:
LETTUCE_TEST_SERVER = 'lettuce.django.server.DjangoServer'
This seem to be an undocumented feature from a following pull request: https://github.com/gabrielfalcao/lettuce/pull/395.