Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between django-webtest and selenium

I have been reading about testing in django. One thing that was recommended was use of django-webtest for functional testing. I found a decent article here that teaches how to go about functional testing in selenium using python. But people have also recommended Ian Bicking's WebTest's extension djagno-webtest to use for testing forms in django. How is testing with webtest and testing with selenium different in context of django forms?

So from functional testing point of view:

How does django-webtest and selenium go side by side?

Do we need to have both of them or any one would do?

like image 297
whatf Avatar asked Sep 16 '12 17:09

whatf


1 Answers

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..)

Bottom line: PREFER to use WebTest, unless you MUST use Selenium for things that can't be tested with WebTest.

like image 190
idanzalz Avatar answered Oct 01 '22 19:10

idanzalz