Created
October 4, 2011 08:21
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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