This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

working for WinXP FF13

  • Loading branch information...
klrmn authored and 6a68 committed Aug 14, 2012
1 parent 4e7a4b8 commit 72331ddd9cbd8e3e72491597006466622e5d55d2
View
@@ -17,3 +17,4 @@ Thumbs.db
/automation-tests/results
/automation-tests/credentials.yaml
/automation-tests/sauce.yaml
+automation-tests/persona_server/results/*
@@ -0,0 +1,115 @@
+#!/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/.
+
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import WebDriverWait
+
+from base import Base
+
+
+class AccountManager(Base):
+ '''AccountManager is used when logged in. Use HomePage page if not logged in.'''
+
+ _page_url = '/'
+ _emails_locator = (By.CSS_SELECTOR, '#emailList .email')
+ _edit_password_button_locator = (By.CSS_SELECTOR, '#edit_password button.edit')
+ _old_password_field_locator = (By.ID, 'old_password')
+ _new_password_field_locator = (By.ID, 'new_password')
+ _change_password_done_locator = (By.ID, 'changePassword')
+ _sign_in_locator = (By.CSS_SELECTOR, 'a.signIn')
+ _sign_out_locator = (By.CSS_SELECTOR, 'a.signOut')
+ _cancel_account_locator = (By.ID, 'cancelAccount')
+
+ def load_page(self):
+ Base.load_page(self)
+ self.wait_for_page_to_load()
+
+ def wait_for_page_to_load(self):
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(*self._emails_locator).is_displayed())
+
+ @property
+ def emails(self):
+ """Returns a textual list of email addresses associated with the currently signed in user."""
+ return [element.text for element in self.selenium.find_elements(*self._emails_locator)]
+
+ def click_edit_password(self):
+ """Click edit password to show the new/old password fields"""
+ self.selenium.find_element(*self._edit_password_button_locator).click()
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(*self._old_password_field_locator).is_displayed())
+
+ @property
+ def old_password(self):
+ """Get the value of the old password field."""
+ return self.selenium.find_element(*self._old_password_field_locator).text
+
+ @old_password.setter
+ def old_password(self, value):
+ """Set the value of the old password field."""
+ password = self.selenium.find_element(*self._old_password_field_locator)
+ password.clear()
+ password.send_keys(value)
+
+ @property
+ def new_password(self):
+ """Get the value of the new password field."""
+ return self.selenium.find_element(*self._new_password_field_locator).text
+
+ @new_password.setter
+ def new_password(self, value):
+ """Set the value of the new password field."""
+ password = self.selenium.find_element(*self._new_password_field_locator)
+ password.clear()
+ password.send_keys(value)
+
+ def click_password_done(self):
+ """Click password done to save the new password."""
+ self.selenium.find_element(*self._change_password_done_locator).click()
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(*self._edit_password_button_locator).is_displayed())
+
+ def click_sign_out(self):
+ """Click the Sign Out button"""
+ self.selenium.find_element(*self._sign_out_locator).click()
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: not self.signed_in)
+
+ def click_cancel_account(self):
+ """Click the cancel account link."""
+ self.selenium.find_element(*self._cancel_account_locator).click()
+
+ def change_password(self, old_password, new_password):
+ """
+ Helper function change_password(old_password, new_password) performs the
+ series of actions necessary to change the password.
+ """
+
+ self.click_edit_password()
+ self.old_password = old_password
+ self.new_password = new_password
+ self.click_password_done()
+
+ def sign_out(self):
+ """
+ Helper function sign_out() performs the series of actions necessary to
+ sign out.
+ """
+
+ self.click_sign_out()
+ from home import HomePage # circular reference
+ return HomePage(self.mozwebqa)
+
+ def cancel_account(self):
+ """
+ Helper function cancel_account() performs the series of actions necessary
+ to cancel the account of the currently signed in user.
+ """
+
+ self.click_cancel_account()
+ self.selenium.switch_to_alert().accept()
+ from home import HomePage # circular reference
+ return HomePage(self.mozwebqa)
@@ -0,0 +1,35 @@
+#!/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/.
+
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import WebDriverWait
+
+
+class Base(object):
+
+ _body_locator = (By.TAG_NAME, 'body')
+
+ def __init__(self, mozwebqa):
+ self.mozwebqa = mozwebqa
+ self.selenium = mozwebqa.selenium
+ self.timeout = mozwebqa.timeout
+ self.base_url = mozwebqa.base_url
+
+ @property
+ def signed_in(self):
+ """Returns True/False whether a user is signed in."""
+ return 'not_authenticated' not in self.selenium.find_element(*self._body_locator).get_attribute('class')
+
+ def load_page(self):
+ if self._page_url:
+ self.selenium.get(self.base_url + self._page_url)
+ self.wait_for_ajax()
+
+ def wait_for_ajax(self):
+ """Waits for the script 'jQuery.active == 0'."""
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.execute_script("return jQuery.active == 0"),
+ "Wait for AJAX timed out after %s seconds" % self.timeout)
@@ -0,0 +1,77 @@
+#!/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/.
+
+from base import Base
+
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import WebDriverWait
+
+
+class CompleteRegistration(Base):
+
+ _page_title = 'Mozilla Persona: Complete Registration'
+ _email_locator = (By.ID, 'email')
+ _password_locator = (By.ID, 'password')
+ _finish_locator = (By.CSS_SELECTOR, 'div.submit > button')
+ _thank_you_locator = (By.ID, 'congrats')
+
+ def __init__(self, mozwebqa, url, expect='redirect'):
+ """
+ class init method
+ :Args:
+ - url - the confirmation url from the email
+ - expect - redirect/success/reset/verify (default redirect)
+ """
+ Base.__init__(self, mozwebqa)
+
+ self.selenium.get(url)
+
+ if expect == 'redirect':
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.title != self._page_title,
+ "Complete Registration page did not redirect")
+ elif expect == 'success':
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: 'Thank you' in s.find_element(*self._thank_you_locator).text,
+ "Complete Registration did not succeed")
+ elif expect == 'reset':
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: 'verified' in s.find_element(*self._thank_you_locator).text,
+ "Complete Registration did not succeed")
+ elif expect == 'verify':
+ WebDriverWait(self.selenium, self.timeout).until(
+ lambda s: s.find_element(*self._password_locator).is_displayed(),
+ "password field did not become visible")
+ else:
+ raise Exception('Unknown expect value: %s' % expect)
+
+ @property
+ def email(self):
+ """Get the value of the email field."""
+ return self.selenium.find_element(*self._email_locator).text
+
+ @property
+ def password(self):
+ """Get the value of the password field."""
+ return self.selenium.find_element(*self._password_locator).text
+
+ @password.setter
+ def password(self, value):
+ """Set the value of the password field."""
+ password = self.selenium.find_element(*self._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())
+
+ @property
+ def thank_you(self):
+ """Returns the 'thank you' message."""
+ return self.selenium.find_element(*self._thank_you_locator).text
@@ -0,0 +1,41 @@
+#!/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 time
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import WebDriverWait
+
+from base import Base
+from sign_in import SignIn
+
+
+class HomePage(Base):
+ '''HomePage is used when not logged in. Use AccountManager page if logged in.'''
+
+ _page_title = 'Mozilla Persona: A Better Way to Sign In'
+ _page_url = '/'
+ _sign_in_locator = (By.CSS_SELECTOR, 'a.signIn')
+ _sign_up_locator = (By.CSS_SELECTOR, 'a.button.create')
+ _manage_section_locator = (By.ID, 'manage')
+ _sign_out_locator = (By.CSS_SELECTOR, 'a.signOut')
+
+ def __init__(self, mozwebqa):
+ Base.__init__(self, mozwebqa)
+
+ WebDriverWait(self.selenium, self.timeout * 2).until(
+ lambda s: s.find_element(*self._sign_in_locator) and \
+ s.find_element(*self._sign_in_locator).is_displayed(),
+ "the sign in button has not appeared within %s" % self.timeout * 2)
+
+ def click_sign_up(self):
+ """Clicks the Sign Up button."""
+ self.selenium.find_element(*self._sign_up_locator).click()
+ return SignIn(self.mozwebqa)
+
+ def click_sign_in(self):
+ """Clicks the Sign In button."""
+ self.selenium.find_element(*self._sign_in_locator).click()
+ return SignIn(self.mozwebqa)
Oops, something went wrong.

0 comments on commit 72331dd

Please sign in to comment.