Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated for changes in 2012.05.25

  • Loading branch information...
commit c4d195206499857ab646177d0a5cf0ab0620e16a 1 parent c02a13a
@davehunt authored
View
15 browser_id.py
@@ -17,20 +17,11 @@ def __init__(self, sel, timeout=60):
selenium.selenium))
self.timeout = timeout
- def sign_in(self, email=None, password=None):
+ def sign_in(self, email, password):
"""Signs in using the specified email address and password."""
if self.selenium.rc:
from pages.rc.sign_in import SignIn
else:
from pages.webdriver.sign_in import SignIn
- if email and password:
- sign_in = SignIn(self.selenium, timeout=self.timeout, expect='new')
- sign_in.sign_in(email, password)
- elif email:
- sign_in = SignIn(self.selenium, timeout=self.timeout, expect='new')
- sign_in.sign_in_new_user(email)
- else:
- sign_in = SignIn(self.selenium,
- timeout=self.timeout,
- expect='returning')
- sign_in.sign_in_returning_user()
+ sign_in = SignIn(self.selenium, timeout=self.timeout, expect='new')
+ sign_in.sign_in(email, password)
View
36 pages/rc/verify_email_address.py → pages/rc/complete_registration.py
@@ -6,21 +6,23 @@
from base import Base
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.ui import WebDriverWait
-
-class VerifyEmailAddress(Base):
+class CompleteRegistration(Base):
_email_locator = 'id=email'
_password_locator = 'id=password'
- _verify_password_locator = 'id=vpassword'
_finish_locator = 'css=div.submit > button'
_thank_you_locator = 'id=congrats'
- def __init__(self, *args, **kwargs):
- Base.__init__(self, *args, **kwargs)
- self.wait_for_element_visible(self._email_locator)
+ def __init__(self, selenium, timeout, expect='success'):
+ Base.__init__(self, selenium, timeout)
+
+ if expect == 'success':
+ self.wait_for_element_visible(self._thank_you_locator)
+ elif expect == 'verify':
+ self.wait_for_element_visible(self._password_locator)
+ else:
+ raise Exception('Unknown expect value: %s' % expect)
@property
def email(self):
@@ -37,22 +39,12 @@ def password(self, value):
"""Set the value of the password field."""
self.selenium.type(self._password_locator, value)
- @property
- def verify_password(self):
- """Get the value of the password field."""
- return self.selenium.get_text(self._verify_password_locator)
-
- @password.setter
- def verify_password(self, value):
- """Set the value of the password field."""
- self.selenium.type(self._verify_password_locator, value)
-
def click_finish(self):
"""Clicks the 'finish' button."""
self.selenium.click(self._finish_locator)
self.wait_for_element_visible(self._thank_you_locator)
- def verify_email_address(self, password):
- self.password = password
- self.verify_password = password
- self.click_finish()
+ @property
+ def thank_you(self):
+ """Returns the 'thank you' message."""
+ return self.selenium.get_text(self._thank_you_locator)
View
17 pages/rc/sign_in.py
@@ -12,10 +12,11 @@ class SignIn(Base):
_signed_in_email_locator = 'css=label[for=email_0]'
_email_locator = 'id=email'
_password_locator = 'id=password'
+ _verify_password_locator = 'id=vpassword'
_next_locator = 'css=button.start'
_sign_in_locator = 'css=button.returning'
_sign_in_returning_user_locator = 'id=signInButton'
- _verify_email_locator = 'css=button.newuser'
+ _verify_email_locator = 'id=verify_user'
_use_another_email_address_locator = 'id=back'
def __init__(self, selenium, timeout, expect='new'):
@@ -60,6 +61,16 @@ def password(self, value):
"""Set the value of the password field."""
self.selenium.type(self._password_locator, value)
+ @property
+ def verify_password(self):
+ """Get the value of the verify password field."""
+ return self.selenium.get_text(self._verify_password_locator)
+
+ @password.setter
+ def verify_password(self, value):
+ """Set the value of the verify password field."""
+ self.selenium.type(self._verify_password_locator, value)
+
def click_next(self, expect='password'):
"""Clicks the 'next' button."""
self.selenium.click(self._next_locator)
@@ -92,10 +103,12 @@ def sign_in(self, email, password):
self.password = password
self.click_sign_in()
- def sign_in_new_user(self, email):
+ def sign_in_new_user(self, email, password):
"""Requests verification email using the specified email address."""
self.email = email
self.click_next(expect='verify')
+ self.password = password
+ self.verify_password = password
self.click_verify_email()
self.close_window()
self.switch_to_main_window()
View
38 pages/webdriver/verify_email_address.py → pages/webdriver/complete_registration.py
@@ -10,18 +10,24 @@
from selenium.webdriver.support.ui import WebDriverWait
-class VerifyEmailAddress(Base):
+class CompleteRegistration(Base):
_email_locator = (By.ID, 'email')
_password_locator = (By.ID, 'password')
- _verify_password_locator = (By.ID, 'vpassword')
_finish_locator = (By.CSS_SELECTOR, 'div.submit > button')
_thank_you_locator = (By.ID, 'congrats')
- def __init__(self, *args, **kwargs):
- Base.__init__(self, *args, **kwargs)
- WebDriverWait(self.selenium, self.timeout).until(
- lambda s: s.find_element(*self._email_locator).is_displayed())
+ def __init__(self, selenium, timeout, expect='success'):
+ Base.__init__(self, selenium, timeout)
+
+ if expect == 'success':
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(*self._thank_you_locator).is_displayed())
+ elif expect == 'verify':
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(*self._password_locator).is_displayed())
+ else:
+ raise Exception('Unknown expect value: %s' % expect)
@property
def email(self):
@@ -40,25 +46,13 @@ def password(self, value):
password.clear()
password.send_keys(value)
- @property
- def verify_password(self):
- """Get the value of the password field."""
- return self.selenium.find_element(*self._verify_password_locator).text
-
- @password.setter
- def verify_password(self, value):
- """Set the value of the password field."""
- password = self.selenium.find_element(*self._verify_password_locator)
- password.clear()
- password.send_keys(value)
-
def click_finish(self):
"""Clicks the 'finish' button."""
self.selenium.find_element(*self._finish_locator).click()
WebDriverWait(self.selenium, self.timeout).until(
lambda s: s.find_element(*self._thank_you_locator).is_displayed())
- def verify_email_address(self, password):
- self.password = password
- self.verify_password = password
- self.click_finish()
+ @property
+ def thank_you(self):
+ """Returns the 'thank you' message."""
+ return self.selenium.find_element(*self._thank_you_locator).text
View
19 pages/webdriver/sign_in.py
@@ -15,10 +15,11 @@ class SignIn(Base):
_signed_in_email_locator = (By.CSS_SELECTOR, 'label[for=email_0]')
_email_locator = (By.ID, 'email')
_password_locator = (By.ID, 'password')
+ _verify_password_locator = (By.ID, 'vpassword')
_next_locator = (By.CSS_SELECTOR, 'button.start')
_sign_in_locator = (By.CSS_SELECTOR, 'button.returning')
_sign_in_returning_user_locator = (By.ID, 'signInButton')
- _verify_email_locator = (By.CSS_SELECTOR, 'button.newuser')
+ _verify_email_locator = (By.ID, 'verify_user')
_use_another_email_address_locator = (By.ID, 'back')
def __init__(self, selenium, timeout, expect='new'):
@@ -72,6 +73,18 @@ def password(self, value):
password.clear()
password.send_keys(value)
+ @property
+ def verify_password(self):
+ """Get the value of the verify password field."""
+ return self.selenium.find_element(*self._verify_password_locator).text
+
+ @password.setter
+ def verify_password(self, value):
+ """Set the value of the verify password field."""
+ password = self.selenium.find_element(*self._verify_password_locator)
+ password.clear()
+ password.send_keys(value)
+
def click_next(self, expect='password'):
"""Clicks the 'next' button."""
self.selenium.find_element(*self._next_locator).click()
@@ -111,10 +124,12 @@ def sign_in(self, email, password):
self.password = password
self.click_sign_in()
- def sign_in_new_user(self, email):
+ def sign_in_new_user(self, email, password):
"""Requests verification email using the specified email address."""
self.email = email
self.click_next(expect='verify')
+ self.password = password
+ self.verify_password = password
self.click_verify_email()
self.close_window()
self.switch_to_main_window()
View
39 tests/rc/check_sign_in.py
@@ -18,7 +18,7 @@
class TestSignIn:
def test_sign_in_helper(self, mozwebqa):
- browser_id = BrowserID(mozwebqa.selenium)
+ browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
browser_id.sign_in(mozwebqa.email, mozwebqa.password)
logout_locator = 'css=#loggedin a'
@@ -39,20 +39,27 @@ def test_sign_in(self, mozwebqa):
def test_sign_in_new_user_helper(self, mozwebqa):
restmail_username = 'bidpom_%s' % uuid.uuid1()
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- print 'signing in as %s@restmail.net' % restmail_username
- browser_id.sign_in('%s@restmail.net' % restmail_username)
+ email = '%s@restmail.net' % restmail_username
+
+ from ...pages.rc.sign_in import SignIn
+ signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
+ 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']
def test_sign_in_new_user(self, mozwebqa):
restmail_username = 'bidpom_%s' % uuid.uuid1()
+ email = '%s@restmail.net' % restmail_username
+ password = 'password'
from ...pages.rc.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
- print 'signing in as %s@restmail.net' % restmail_username
- signin.email = '%s@restmail.net' % restmail_username
+ print 'signing in as %s' % email
+ signin.email = email
signin.click_next(expect='verify')
+ signin.password = password
+ signin.verify_password = password
signin.click_verify_email()
signin.close_window()
signin.switch_to_main_window()
@@ -66,8 +73,9 @@ def test_sign_in_returning_user_helper(self, mozwebqa):
mozwebqa.wait_for_element_visible(mozwebqa, login_locator)
mozwebqa.selenium.click(login_locator)
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in()
+ from ...pages.rc.sign_in import SignIn
+ signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='returning')
+ signin.sign_in_returning_user()
logout_locator = 'css=#loggedin a'
mozwebqa.wait_for_element_visible(mozwebqa, logout_locator)
assert mozwebqa.selenium.is_visible(logout_locator)
@@ -94,13 +102,18 @@ def create_verified_user(self, selenium, timeout):
restmail_username = 'bidpom_%s' % uuid.uuid1()
email = '%s@restmail.net' % restmail_username
password = 'password'
- browser_id = BrowserID(selenium, timeout)
- browser_id.sign_in(email)
+
+ from ...pages.rc.sign_in import SignIn
+ signin = SignIn(selenium, timeout, expect='new')
+ signin.sign_in_new_user(email, password)
mail = restmail.get_mail(restmail_username)
verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
mail[0]['text']).group(0)
+
selenium.open(verify_url)
- from ...pages.rc.verify_email_address import VerifyEmailAddress
- verify_email_address = VerifyEmailAddress(selenium, timeout)
- verify_email_address.verify_email_address(password)
+ from ...pages.rc.complete_registration import CompleteRegistration
+ complete_registration = CompleteRegistration(selenium,
+ timeout,
+ expect='success')
+ assert 'Thank you' in complete_registration.thank_you
return (email, password)
View
50 tests/rc/check_verify_email_address.py
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# 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/.
-
-import re
-import uuid
-
-import pytest
-
-from .. import restmail
-
-
-@pytest.mark.nondestructive
-class TestVerifyEmailAddress:
-
- def test_verify_email_address_helper(self, mozwebqa):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
-
- from ... import BrowserID
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in('%s@restmail.net' % restmail_username)
- mail = restmail.get_mail(restmail_username)
- verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
- mail[0]['text']).group(0)
- mozwebqa.selenium.open(verify_url)
-
- from ...pages.rc.verify_email_address import VerifyEmailAddress
- verify_email_address = VerifyEmailAddress(mozwebqa.selenium,
- mozwebqa.timeout)
- verify_email_address.verify_email_address('password')
-
- def test_verify_email_address(self, mozwebqa):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
-
- from ... import BrowserID
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in('%s@restmail.net' % restmail_username)
- mail = restmail.get_mail(restmail_username)
- verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
- mail[0]['text']).group(0)
- mozwebqa.selenium.open(verify_url)
-
- from ...pages.rc.verify_email_address import VerifyEmailAddress
- verify_email_address = VerifyEmailAddress(mozwebqa.selenium,
- mozwebqa.timeout)
- verify_email_address.password = 'password'
- verify_email_address.verify_password = 'password'
- verify_email_address.click_finish()
View
37 tests/webdriver/check_sign_in.py
@@ -37,20 +37,27 @@ def test_sign_in(self, mozwebqa):
def test_sign_in_new_user_helper(self, mozwebqa):
restmail_username = 'bidpom_%s' % uuid.uuid1()
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- print 'signing in as %s@restmail.net' % restmail_username
- browser_id.sign_in('%s@restmail.net' % restmail_username)
+ email = '%s@restmail.net' % restmail_username
+
+ from ...pages.webdriver.sign_in import SignIn
+ signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
+ 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']
def test_sign_in_new_user(self, mozwebqa):
restmail_username = 'bidpom_%s' % uuid.uuid1()
+ email = '%s@restmail.net' % restmail_username
+ password = 'password'
from ...pages.webdriver.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
- print 'signing in as %s@restmail.net' % restmail_username
- signin.email = '%s@restmail.net' % restmail_username
+ print 'signing in as %s' % email
+ signin.email = email
signin.click_next(expect='verify')
+ signin.password = password
+ signin.verify_password = password
signin.click_verify_email()
signin.close_window()
signin.switch_to_main_window()
@@ -65,8 +72,9 @@ def test_sign_in_returning_user_helper(self, mozwebqa):
mozwebqa.selenium.find_element_by_id('loggedout'). \
find_element_by_tag_name('button').click()
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in()
+ from ...pages.webdriver.sign_in import SignIn
+ signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='returning')
+ signin.sign_in_returning_user()
WebDriverWait(mozwebqa.selenium, mozwebqa.timeout).until(
lambda s: s.find_element_by_id('loggedin').is_displayed())
@@ -92,13 +100,18 @@ def create_verified_user(self, selenium, timeout):
restmail_username = 'bidpom_%s' % uuid.uuid1()
email = '%s@restmail.net' % restmail_username
password = 'password'
- browser_id = BrowserID(selenium, timeout)
- browser_id.sign_in(email)
+
+ from ...pages.webdriver.sign_in import SignIn
+ signin = SignIn(selenium, timeout, expect='new')
+ signin.sign_in_new_user(email, password)
mail = restmail.get_mail(restmail_username)
verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
mail[0]['text']).group(0)
+
selenium.get(verify_url)
- from ...pages.webdriver.verify_email_address import VerifyEmailAddress
- verify_email_address = VerifyEmailAddress(selenium, timeout)
- verify_email_address.verify_email_address(password)
+ from ...pages.webdriver.complete_registration import CompleteRegistration
+ complete_registration = CompleteRegistration(selenium,
+ timeout,
+ expect='success')
+ assert 'Thank you' in complete_registration.thank_you
return (email, password)
View
51 tests/webdriver/check_verify_email_address.py
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# 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/.
-
-import re
-import uuid
-
-import pytest
-from selenium.webdriver.support.ui import WebDriverWait
-
-from .. import restmail
-
-
-@pytest.mark.nondestructive
-class TestVerifyEmailAddress:
-
- def test_verify_email_address_helper(self, mozwebqa):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
-
- from ... import BrowserID
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in('%s@restmail.net' % restmail_username)
- mail = restmail.get_mail(restmail_username)
- verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
- mail[0]['text']).group(0)
- mozwebqa.selenium.get(verify_url)
-
- from ...pages.webdriver.verify_email_address import VerifyEmailAddress
- verify_email_address = VerifyEmailAddress(mozwebqa.selenium,
- mozwebqa.timeout)
- verify_email_address.verify_email_address('password')
-
- def test_verify_email_address(self, mozwebqa):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
-
- from ... import BrowserID
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in('%s@restmail.net' % restmail_username)
- mail = restmail.get_mail(restmail_username)
- verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
- mail[0]['text']).group(0)
- mozwebqa.selenium.get(verify_url)
-
- from ...pages.webdriver.verify_email_address import VerifyEmailAddress
- verify_email_address = VerifyEmailAddress(mozwebqa.selenium,
- mozwebqa.timeout)
- verify_email_address.password = 'password'
- verify_email_address.verify_password = 'password'
- verify_email_address.click_finish()
Please sign in to comment.
Something went wrong with that request. Please try again.