Here is some “science fiction” I’m working on at the moment for testing the Django admin app with Selenium. I call it science fiction because the I’m still working on the code that will actually read this and execute it correctly in the browser.
I imagine the source document will be HTML with a scent of ReStructuredText and a dash of Doctest. The intention is that the “doctest” code is written in JavaScript, interpreted and executed by the Selenium engine on the fly inside the browser.
----- begin 'spot test' source code ----------
========================
See.Spot.Login.to.Django
========================
To modify data in Django, you'll need to login to the
administrative application with your username and
password. For the purposes of this demonstration,
I'll assume you are a dog and that your name is 'Spot'.
First, please navigate to the login page.
>>> see.spot.open.the.url ('http://localhost:8080/admin')
You should now see a page with a form asking for
username and password.
>>> var username = see.spot.get ('username')
>>> var password = see.spot.get ('password')
>>> see.spot.type(username).into.the.field.id ('username')
>>> see.spot.type(password).into.the.field.id ('password')
>>> see.spot.click.the.button.where ('id', 'submit')
Verify that you're now logged in and that you see
the main administrative dashboard.
>>> see.spot.verify.page.text.containts ('Welcome, Spot')
>>> see.spot.verify.existence.of.link ('text', 'Log out')
==========================
See.Spot.Log.out.of.Django
==========================
When you're done editing data in Django, it's good
practice to log out. Logging out will expire your session
cookie and prevent other people from using your login
credentials with the same computer and browser.
>>> see.spot.click.the.link.where ('id', 'logout')
>>> see.spot.verify.page.text.contains ('Thanks')
>>> see.spot.verify.exisitence.of.link ('text', 'Log in again')
You are now logged out! Good boy, Spot!
----- end ----------------------------------



Cool. I use django, but haven’t messed with Selenium yet, so I’m looking forward to it :)
Link | July 7th, 2006 at 5:05 pm
Yup, looks very promising!
Link | July 8th, 2006 at 9:38 am
hope we could open it and improve it together.
Link | July 9th, 2006 at 10:14 am