The important thing to know about Selenium is that it’s primarily built to be a server-agnostic testing framework. It doesn’t matter what framework or server-side implementation is used to create the front-end as long as it behaves as expected. Also, while you can (and when possible you probably should) write tests manually in Selenium, many tests are recorded macros of someone going through the motions that are then turned into code automatically.
On the other hand, django-webtest is built to work specifically on Django websites. It’s actually a Django-specific extension to WebTest, which is not Django-only, but WSGI-only (and therefore Python-only). Because of that, it can interact with the application with a higher level of awareness of how things work on the server. This can make running tests faster and can also makes it easy to write more granular, detailed tests. Also, unlike Selenium, your tests can’t be automatically written as recorded macros.
Otherwise, the two tools have generally the same purpose and are intended to test the same kinds of things. That said, I would suggest picking one rather than using both.
The key difference is that selenium runs an actual browser, while WebTest hooks to the WSGI.
This results in the following differences:
- You can’t test JS code with WebTest, since there is nothing to run it.
- WebTest is much faster since it hooks to the WSGI, this also means a smaller memory footprint
- WebTest does not require to actually run the server on a port so it’s a bit easier to parallize
- WebTest does not check different problems that occur with actual browsers, like specific browser version bugs (cough.. internet explorer.. cough..)
PREFER to use WebTest, unless you MUST use Selenium for things that can’t be tested with WebTest.
- How to remove Add button in Django admin, for specific Model?
- Django how to get count for manytomany field
- Create a canonical "parent" product in Django Oscar programmatically
- Django Check and set permissions for a user group
- Exclude field from values() or values_list()