Skip to content

Commit

Permalink
FT for login with Persona
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarrell-vz committed Oct 20, 2014
1 parent 2e1d27b commit 112fcf6
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions functional_tests/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from selenium.webdriver.support.ui import WebDriverWait
import time
from .base import FunctionalTest

class LoginTest(FunctionalTest):

def wait_for_element_with_id(self, element_id):
WebDriverWait(self.browser, timeout=30).until(
lambda b: b.find_element_by_id(element_id)
)

def switch_to_new_window(self, text_in_title):
retries = 60
while retries > 0:
for handle in self.browser.window_handles:
self.browser.switch_to_window(handle)
if text_in_title in self.browser.title:
return
retries -= 1
time.sleep(0.5)
self.fail('could not find window')

def test_login_with_persona(self):
# Rob goes to the awesome superlists site
# and notices a 'Sign in' link for the first time.
self.browser.get(self.server_url)
self.browser.find_element_by_id('login').click()

# A Persona login box appears
self.switch_to_new_window('Mozilla Persona')

# Rob logs in with his email address
## use mockmyid.com for test email
self.browser.find_element_by_id(
'authentication_email'
).send_keys('[email protected]')
self.browser.find_element_by_tag_name('button').click()

# The Persona window closes
self.switch_to_new_window('To-Do')

# Rob can see that he is logged in
self.wait_for_element_with_id('logout')
navbar = self.browser.find_element_by_css_selector('.navbar')
self.assertIn('[email protected]', navbar.text)


0 comments on commit 112fcf6

Please sign in to comment.