开发者

Selenium and Django: how to mock the server?

I'm starting to introduce Selenium tests to my website that is written in Django. The browser开发者_运维百科 that is controlled by Selenium needs some server to connect. So far I just run my full application in a separate process, but this is painful.

I'd like to run some mock HTTP server, make it serve all the necessary static files and render Django templates and return mock responses to some specific requests.

How would you do that?


Can you not run Selenium over django dev server http://localhost:8000/ .

If not perhaps worth looking at http://harry.pythonanywhere.com/ .where there are some good resources


The best thing is to integrate selenium tests into your unit test suite. When Django 1.4 comes out this will be a supported feature, where the Django test runner will run a development HTTP server for you while the tests run, and load all of your test fixtures for you:

support-for-in-browser-testing-frameworks
LiveServerTestCase

Likely you can't wait until the 1.4 release. In the meantime, you can use something called django-nose-selenium to do this:
https://github.com/weluse/django-nose-selenium
There's a good comprehensive guide on how to do this here:
http://timescapers.com/2011/08/27/django-nose-selenium-a-concise-tutorial/


If I may plug-plug my own tutorial, which will allow you to do full selenium testing against the django test server

http://www.tdd-django-tutorial.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜