Django: Ticket #2867: Add native Selenium support to django.test framework.https://code.djangoproject.com/ticket/2867
<p>
Selenium is an increasingly popular functional testing framework.
</p>
<p>
Selenium comes packaged with a Python RC (Remote Control) library. The typical use is to leverage unittest to run and record Selenium results. Since we already support unittest it shouldn't be much work to get some nicely integrated Selenium support in the django.test framework.
</p>
en-usDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/ticket/2867
Trac 1.2mikeal@…Tue, 03 Oct 2006 20:49:57 GMTcomponent changedhttps://code.djangoproject.com/ticket/2867#comment:1
https://code.djangoproject.com/ticket/2867#comment:1
<ul>
<li><strong>component</strong>
changed from <em>Admin interface</em> to <em>Unit test system</em>
</li>
</ul>
<p>
I'll be working on this over the next few weeks. Hoping to have a patch ready by end of October.
</p>
TicketanonymousTue, 03 Oct 2006 20:57:55 GMThttps://code.djangoproject.com/ticket/2867#comment:2
https://code.djangoproject.com/ticket/2867#comment:2
<p>
The implementation I'm planning on going with is to create a unittest.TestCase subclass for selenium tests that defines setUp and tearDown.
</p>
<p>
Then patching the <code>./manage.py test</code> to check for those subclasses in myapp.tests. This means that each test class defined will bring up a new browser window and run all tests in that class.
</p>
<p>
The user will need a standard place to define the location of their browser application. I'll be writing in some sane defaults but they are really just guesses since we don't know which browser the user wants to use or if it's installed in the default location. Where is a good place for the user to define this variable?
</p>
TicketJacobTue, 03 Oct 2006 21:02:08 GMThttps://code.djangoproject.com/ticket/2867#comment:3
https://code.djangoproject.com/ticket/2867#comment:3
<p>
Wow, I'm very excited to see what you come up with!
</p>
<p>
I don't think you need to have a user setting for the browser app since I'm pretty sure that the <code>webbrowser</code> module will figure out what the user's default browser is. If for some reason that doesn't work, however, I'd say the settings file is the right place for those options.
</p>
TicketAdrian HolovatyTue, 03 Oct 2006 21:02:41 GMThttps://code.djangoproject.com/ticket/2867#comment:4
https://code.djangoproject.com/ticket/2867#comment:4
<p>
FYI, Jason Huggins, the creator of Selenium, is a longtime Django dude and may be interested in helping you with this. I think he might already have something started.
</p>
TicketanonymousSat, 07 Oct 2006 02:05:59 GMThttps://code.djangoproject.com/ticket/2867#comment:5
https://code.djangoproject.com/ticket/2867#comment:5
<p>
This ticket now depends on <a class="closed ticket" href="https://code.djangoproject.com/ticket/2879" title="#2879: New feature: Add live test server support to test framework (closed: fixed)">ticket:2879</a> being accepted and committed.
</p>
<p>
I wrote the live test server support and put it in the other ticket because it's useful enough on it's own, but this obviously can't be resolved without it.
</p>
Ticketmir@…Tue, 30 Jan 2007 21:25:30 GMTstage changed; keywords sethttps://code.djangoproject.com/ticket/2867#comment:6
https://code.djangoproject.com/ticket/2867#comment:6
<ul>
<li><strong>keywords</strong>
<em>selenium</em> added
</li>
<li><strong>stage</strong>
changed from <em>Unreviewed</em> to <em>Accepted</em>
</li>
</ul>
<p>
Based on Jacob's comment -&gt; Accepted
</p>
TicketanonymousTue, 30 Jan 2007 21:42:49 GMThttps://code.djangoproject.com/ticket/2867#comment:7
https://code.djangoproject.com/ticket/2867#comment:7
<p>
Important update.
</p>
<p>
After months of trying to make Selenium not break on me every week myself and another developer at OSAF wrote a replacement. It's 100% js and python and will be announced publicly sometime in March, hopefully with a presentation at OSCON.
</p>
<p>
I'll be happy to create another ticket after March to add support for that system rather than Selenium but I won't be able to add Selenium support in this ticket.
</p>
<p>
Notes for whoever may write this:
</p>
<p>
The biggest problem someone else implementing this will run in to is interfacing with the Selenium RC server, and in turn interfacing with the browserbot through the server to get useful information about failures. The SeleniumRC server is in java and fairly unflexible.
</p>
<p>
It also doesn't support a real RPC protocol for the remote client library, all commands to the RC are communicated over URL parameters passed to the proxy and there isn't a very steady communication workflow between the RPC client and the server OR the RC server and the browserbot. The architecture makes it very pritle and nearly impossible to debug, especially in a continuous environment like an automated build/test system.
</p>
<p>
Also, you'll want to just maintain your own branch of the python remote client library. The method calls which translate into browser actions are all statically defined in the module, so any custom methods in the user_extensions won't work. It's about 8 lines to write a real dynamic wrapper in <span class="underline">getattr</span> to call remote selenium methods, but they won't accept the patch over at Selenium because "we write the file dynamically at build time via XSLT, so it is dynamic and doesn't need dynamic method generation. And we use that then we don't get pretty api documentation". Ewwwwwwwwwwwwwwwwwwwww.
</p>
Ticketmikeal@…Tue, 30 Jan 2007 21:44:58 GMThttps://code.djangoproject.com/ticket/2867#comment:8
https://code.djangoproject.com/ticket/2867#comment:8
<p>
Sorry for not putting my name. The last comment was me :)
</p>
TicketSimon G. <dev@…>Fri, 14 Sep 2007 09:27:47 GMTstatus changed; resolution sethttps://code.djangoproject.com/ticket/2867#comment:9
https://code.djangoproject.com/ticket/2867#comment:9
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>wontfix</em>
</li>
</ul>
<p>
ok, closing this as wontfix given the comments above. If someone *does* implement some selenium support then please create a new ticket.
</p>
TicketAlmadTue, 13 Jan 2009 15:15:13 GMThttps://code.djangoproject.com/ticket/2867#comment:10
https://code.djangoproject.com/ticket/2867#comment:10
<p>
For the record, I wrote liveserver in similar way to WindmillTestCase and integrated it with Selenium, works fine for me. Implemented in trunk of <a class="ext-link" href="http://devel.almad.net/trac/django-sane-testing"><span class="icon">​</span>django-sane-testing</a> (will be in 0.2 released this week), works fine for me - just subclass djangosanetesting.cases.SeleniumTestCase and enjoy self.selenium.
</p>
Ticket