-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tfarrell-vz
committed
Oct 20, 2014
1 parent
2e1d27b
commit 112fcf6
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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) | ||
|
||
|