Skip to content

Instantly share code, notes, and snippets.

@pplante
Created October 4, 2011 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pplante/1261140 to your computer and use it in GitHub Desktop.
Save pplante/1261140 to your computer and use it in GitHub Desktop.
I wasn't happy with the existing selenium integrations for django, so I wrote one that is compatible with my python-expectations library. Here is a sample test that logs into admin, then checks for my username in the header.
class ApplicationViewTests(SeleniumTestCase):
def test_django_test_server_is_running(self):
self.login()
with self.navigate_to('/admin') as page:
expect(page).to_have_selector('#user-tools')
expect(page.find('#user-tools')).to_contain_text('Welcome, pplante.')
def login(self, username=None, password=None):
with self.navigate_to('/admin') as page:
expect(page).to_have_selector('#login-form')
page.find('#id_username').send_keys('pplante')
page.find('#id_password').send_keys('HAHAPASSWORDS')
page.find('input[type=submit]').click()
time.sleep(0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment