Permalink
Browse files

Updated to reflect recent changes.

  • Loading branch information...
1 parent 377269d commit 8cda4d0fe21def50ebd4db1b0b06508dc78f49e6 @davehunt committed Jul 4, 2012
View
@@ -17,7 +17,7 @@ class SignIn(Base):
_sign_in_locator = 'css=button.returning'
_sign_in_returning_user_locator = 'id=signInButton'
_verify_email_locator = 'id=verify_user'
- _use_another_email_address_locator = 'id=back'
+ _check_email_at_locator = 'css=#wait .contents h2 + p strong'
def __init__(self, selenium, timeout, expect='new'):
Base.__init__(self, selenium, timeout)
@@ -71,6 +71,11 @@ def verify_password(self, value):
"""Set the value of the verify password field."""
self.selenium.type(self._verify_password_locator, value)
+ @property
+ def check_email_at_address(self):
+ """Get the value of the email address for confirmation."""
+ return self.selenium.get_text(self._check_email_at_locator)
+
def click_next(self, expect='password'):
"""Clicks the 'next' button."""
self.selenium.click(self._next_locator)
@@ -94,7 +99,7 @@ def click_sign_in_returning_user(self):
def click_verify_email(self):
"""Clicks 'verify email' button."""
self.selenium.click(self._verify_email_locator)
- self.wait_for_element_visible(self._use_another_email_address_locator)
+ self.wait_for_element_visible(self._check_email_at_locator)
def sign_in(self, email, password):
"""Signs in using the specified email address and password."""
@@ -26,6 +26,10 @@ def __init__(self, selenium, timeout):
WebDriverWait(self.selenium, self.timeout).until(
lambda s: s.find_element(*self._emails_locator).is_displayed())
+ @property
+ def signed_in(self):
+ return 'not_authenticated' not in self.selenium.find_element(By.TAG_NAME, 'body').get_attribute('class')
+
@property
def emails(self):
return [element.text for element in self.selenium.find_elements(*self._emails_locator)]
@@ -69,4 +73,4 @@ def click_password_done(self):
def click_sign_out(self):
self.selenium.find_element(*self._sign_out_locator).click()
WebDriverWait(self.selenium, self.timeout).until(
- lambda s: s.find_element(*self._sign_in_locator).is_displayed())
+ lambda s: not self.signed_in)
@@ -20,7 +20,7 @@ class SignIn(Base):
_sign_in_locator = (By.CSS_SELECTOR, 'button.returning')
_sign_in_returning_user_locator = (By.ID, 'signInButton')
_verify_email_locator = (By.ID, 'verify_user')
- _use_another_email_address_locator = (By.ID, 'back')
+ _check_email_at_locator = (By.CSS_SELECTOR, '#wait .contents h2 + p strong')
def __init__(self, selenium, timeout, expect='new'):
Base.__init__(self, selenium, timeout)
@@ -88,6 +88,11 @@ def verify_password(self, value):
password.clear()
password.send_keys(value)
+ @property
+ def check_email_at_address(self):
+ """Get the value of the email address for confirmation."""
+ return self.selenium.find_element(*self._check_email_at_locator).text
+
def click_next(self, expect='password'):
"""Clicks the 'next' button."""
self.selenium.find_element(*self._next_locator).click()
@@ -118,7 +123,7 @@ def click_verify_email(self):
self.selenium.find_element(*self._verify_email_locator).click()
WebDriverWait(self.selenium, self.timeout).until(
lambda s: s.find_element(
- *self._use_another_email_address_locator).is_displayed())
+ *self._check_email_at_locator).is_displayed())
def sign_in(self, email, password):
"""Signs in using the specified email address and password."""
@@ -47,7 +47,7 @@ def test_sign_in_new_user_helper(self, mozwebqa):
print 'signing in as %s' % email
signin.sign_in_new_user(email, 'password')
mail = restmail.get_mail(restmail_username)
- assert 'Thanks for verifying' in mail[0]['text']
+ assert 'Click to confirm this email address' in mail[0]['text']
@pytest.mark.travis
def test_sign_in_new_user(self, mozwebqa):
@@ -63,10 +63,12 @@ def test_sign_in_new_user(self, mozwebqa):
signin.password = password
signin.verify_password = password
signin.click_verify_email()
+ assert signin.check_email_at_address == email
+
signin.close_window()
signin.switch_to_main_window()
mail = restmail.get_mail(restmail_username)
- assert 'Thanks for verifying' in mail[0]['text']
+ assert 'Click to confirm this email address' in mail[0]['text']
@pytest.mark.travis
def test_sign_in_returning_user(self, mozwebqa):
@@ -45,7 +45,7 @@ def test_sign_in_new_user_helper(self, mozwebqa):
print 'signing in as %s' % email
signin.sign_in_new_user(email, 'password')
mail = restmail.get_mail(restmail_username)
- assert 'Thanks for verifying' in mail[0]['text']
+ assert 'Click to confirm this email address' in mail[0]['text']
@pytest.mark.travis
def test_sign_in_new_user(self, mozwebqa):
@@ -61,10 +61,12 @@ def test_sign_in_new_user(self, mozwebqa):
signin.password = password
signin.verify_password = password
signin.click_verify_email()
+ assert signin.check_email_at_address == email
+
signin.close_window()
signin.switch_to_main_window()
mail = restmail.get_mail(restmail_username)
- assert 'Thanks for verifying' in mail[0]['text']
+ assert 'Click to confirm this email address' in mail[0]['text']
@pytest.mark.travis
def test_sign_in_returning_user(self, mozwebqa):
@@ -4,16 +4,17 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from selenium.webdriver.support.ui import WebDriverWait
+
def pytest_runtest_setup(item):
item.config.option.api = 'webdriver'
def pytest_funcarg__mozwebqa(request):
mozwebqa = request.getfuncargvalue('mozwebqa')
- mozwebqa.selenium.implicitly_wait(10)
mozwebqa.selenium.get('%s/' % mozwebqa.base_url)
- mozwebqa.selenium.find_element_by_id('loggedout'). \
- find_element_by_tag_name('button').click()
- mozwebqa.selenium.implicitly_wait(0)
+ WebDriverWait(mozwebqa.selenium, mozwebqa.timeout).until(
+ lambda s: s.find_element_by_css_selector('#loggedout button').is_displayed())
+ mozwebqa.selenium.find_element_by_css_selector('#loggedout button').click()
return mozwebqa

0 comments on commit 8cda4d0

Please sign in to comment.