Re: selenium test for fallback page loaded from app cache when server is unavailable

72 views
Skip to first unread message

Brad Pitcher

unread,
Nov 3, 2012, 12:29:49 PM11/3/12
to django...@googlegroups.com

Are you having the selenium test go to online.html first like in your manual test?
Maybe you need to have selenium hit offline.html first and cache that page?

On Nov 3, 2012 6:14 AM, "Joao Coelho" <redco...@gmail.com> wrote:
Hi. I haven't been able to figure this one out. Trying to write an automated test that uses selenium.webdriver.firefox.webdriver

The manifest file has
FALLBACK:
/online.html /offline.html

So that at /online.html the browser displays the cached copy of /offline.html when the server is offline

Also, to simulate server unavailable for testing
/online.html returns a 200 response
/online.html?offline=1 returns 503

This all works fine when I browse manually
/online.html displays "I am online"
/online.html?offline=1 displays "I am a cached page"

I want the selenium test to get /online.html?offline=1 and see "I am a cached page" /offline.html
But it's only showing a blank page
I think it's stopping at the 503 and not loading from the app cache

    def test_offline(self):
        """Simulate site being offline"""
        self.selenium.get('%s%s' % (self.live_server_url, '/online.html?offline=1'))
        self.assertIn('cached page', self.selenium.page_source)

How can I make it test this? Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/YrAnOOsSaKAJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages