Skip to content
Browse files

Add 'add new email' for multiple-email logins.

  • Loading branch information...
1 parent fa54c09 commit d2d0660c01d9236acd13546ae5fc33f8c9bc0ab5 Zac committed with Zac Jun 29, 2012
Showing with 58 additions and 1 deletion.
  1. +58 −1 pages/webdriver/sign_in.py
View
59 pages/webdriver/sign_in.py
@@ -9,11 +9,13 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
+import time
class SignIn(Base):
- _signed_in_email_locator = (By.CSS_SELECTOR, 'label[for=email_0]')
_this_is_not_me_locator = (By.ID, 'thisIsNotMe')
+ _signed_in_email_locator = (By.XPATH, "//label[input[@checked='checked']]")
+ _listed_emails_locator = (By.XPATH, "//label[input[@name='email']]")
_email_locator = (By.ID, 'email')
_password_locator = (By.ID, 'password')
_verify_password_locator = (By.ID, 'vpassword')
@@ -24,6 +26,9 @@ class SignIn(Base):
_forgot_password_locator = (By.ID, 'forgotPassword')
_reset_password_locator = (By.ID, 'password_reset')
_check_email_at_locator = (By.CSS_SELECTOR, '#wait .contents h2 + p strong')
+ _add_another_email_locator = (By.ID, 'useNewEmail')
+ _new_email_locator = (By.ID, 'newEmail')
+ _add_new_email_locator = (By.ID, 'addNewEmail')
def __init__(self, selenium, timeout, expect='new'):
Base.__init__(self, selenium, timeout)
@@ -44,6 +49,7 @@ def __init__(self, selenium, timeout, expect='new'):
WebDriverWait(self.selenium, self.timeout).until(
lambda s: s.find_element(
*self._sign_in_returning_user_locator).is_displayed())
+ time.sleep(2)
else:
raise Exception('Unknown expect value: %s' % expect)
@@ -62,6 +68,11 @@ def click_this_is_not_me(self):
lambda s: s.find_element(*self._email_locator).is_displayed())
@property
+ def emails(self):
+ """ Lists the emails for the returning user """
+ return [element.text for element in self.selenium.find_elements(*self._listed_emails_locator)]
+
+ @property
def email(self):
"""Get the value of the email field."""
return self.selenium.find_element(*self._email_locator).text
@@ -74,6 +85,31 @@ def email(self, value):
email.send_keys(value)
@property
+ def new_email(self):
+ """Get the value of the new email field."""
+ return self.selenium.find_element(*self._new_email_locator).text
+
+ @new_email.setter
+ def new_email(self, value):
+ """Set the value of the new email field."""
+ email = self.selenium.find_element(*self._new_email_locator)
+ email.clear()
+ email.send_keys(value)
+
+ @property
+ def selected_email(self):
+ """Return the value of the selected email of returning user's multiple emails"""
+ return self.signed_in_email
+
+ def select_email_checkbox(self, value):
+ """ Select email from the returning user's multiple emails """
+ checkbox = self.selenium.find_element(By.CSS_SELECTOR, "input[value='%s']" % value)
+ checkbox.click()
+
+ def check_email_at_address(self):
+ return self.selenium.find_element(*self._check_email_at_locator).text
+
+ @property
def password(self):
"""Get the value of the password field."""
return self.selenium.find_element(*self._password_locator).text
@@ -148,6 +184,20 @@ def click_reset_password(self):
lambda s: s.find_element(
*self._check_email_at_locator).is_displayed())
+ def click_add_another_email_address(self):
+ """Clicks 'add another email' button."""
+ self.selenium.find_element(*self._add_another_email_locator).click()
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(
+ *self._add_new_email_locator).is_displayed())
+
+ def click_add_new_email(self):
+ """Clicks 'Add' button to insert new email address."""
+ self.selenium.find_element(*self._add_new_email_locator).click()
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(
+ *self._check_email_at_locator).is_displayed())
+
def sign_in(self, email, password):
"""Signs in using the specified email address and password."""
self.email = email
@@ -168,3 +218,10 @@ def sign_in_new_user(self, email, password):
def sign_in_returning_user(self):
"""Signs in with the stored user."""
self.click_sign_in_returning_user()
+
+ def sign_in_add_another_email(self, email):
+ self.click_add_another_email_address()
+ self.new_email = email
+ self.click_add_new_email()
+ self.close_window()
+ self.switch_to_main_window()

0 comments on commit d2d0660

Please sign in to comment.
Something went wrong with that request. Please try again.