Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add more newsletter tests for other forms (international, etc)

  • Loading branch information...
commit c9ffeec6af723ca6d4b7039807ead8a144fb5238 1 parent 7209685
@jlongster jlongster authored
Showing with 152 additions and 34 deletions.
  1. +2 −1  .gitignore
  2. +88 −13 pages/desktop/newsletter.py
  3. +62 −20 test_newsletter.py
View
3  .gitignore
@@ -1,4 +1,5 @@
*.py[co]
rmpyc.sh
/debug/**
-
+results
+venv
View
101 pages/desktop/newsletter.py
@@ -41,29 +41,104 @@
class NewsletterPage(MozillaBasePage):
- _email_locator = "css=.email"
- _agree_to_privacy_policy_checkbox_locator = "css=.privacy-check"
- _submit_button_locator = "css=.subscribe"
- _privacy_policy_error_locator = "css=.privacy-error"
- _success_pane_locator = "css=.success-pane"
+ _email_sel = "css=.email"
+ _agree_to_privacy_policy_checkbox_sel = "css=.privacy-check"
+ _submit_button_sel = "css=#content input[name=submit]"
+ _privacy_policy_error_sel = "css=.privacy-field.field-error"
+ _success_pane_sel = "css=.success-pane"
- def go_to_newsletter_page(self):
- self.selenium.open("/en-US/newsletter/")
+ def go_to_newsletter_page(self, url='/en-US/newsletter/'):
+ self.selenium.open(url)
def type_email(self, email):
- self.selenium.type(self._email_locator, email)
+ self.selenium.type(self._email_sel, email)
def agree_to_privacy_policy(self):
- self.selenium.check(self._agree_to_privacy_policy_checkbox_locator)
+ self.selenium.check(self._agree_to_privacy_policy_checkbox_sel)
def click_sign_me_up(self):
- self.selenium.click(self._submit_button_locator)
+ self.selenium.click(self._submit_button_sel)
self.selenium.wait_for_page_to_load(self.timeout)
@property
def is_privacy_policy_error_visible(self):
- return self.is_element_visible(self._privacy_policy_error_locator)
+ return self.is_element_visible(self._privacy_policy_error_sel)
+
+ @property
+ def is_success_visible(self):
+ return self.is_element_visible(self._success_pane_sel)
+
+
+class MainNewsletterPage(NewsletterPage):
+
+ _other_newsletters_sel = "css=#other-newsletters"
+
+ @property
+ def is_success_visible(self):
+ return self.is_element_visible(self._other_newsletters_sel)
+
+
+class OtherNewsletterPage(MozillaBasePage):
+
+ _email_sel = "css=input[name=email]"
+ _country_sel = "css=select[name=country]"
+ _lang_sel = "css=select[name=lang]"
+ _mozilla_and_you_sel = "css=input[name=mozilla-and-you]"
+ _submit_sel = "css=input[name=submit]"
+ _form_sel = "css=#content form"
+
+ def goto_page(self, email, country, lang, format):
+ self._format_sel = 'css=input[name=format][value=%s]' % format
+ self.selenium.open('/en-US/newsletter/new/?email=%s&country=%s&lang=%s&format=%s'
+ % (email, country, lang, format))
+
+ def get_email(self):
+ return self.selenium.get_value(self._email_sel)
+
+ def get_country(self):
+ return self.selenium.get_value(self._country_sel)
+
+ def get_lang(self):
+ return self.selenium.get_value(self._lang_sel)
+
+ def get_format(self):
+ return (self.selenium.get_value(self._format_sel) == 'on' and
+ self.selenium.get_attribute(self._format_sel + '@value'))
+
+ def click_submit(self):
+ self.selenium.click(self._submit_sel)
+ self.selenium.wait_for_page_to_load(self.timeout)
+
+ @property
+ def is_mozilla_and_you_selected(self):
+ return self.selenium.get_value(self._mozilla_and_you_sel) == 'on'
+
+ @property
+ def is_form_visible(self):
+ return self.selenium.is_element_present(self._form_sel)
+
+ @property
+ def is_success_visible(self):
+ return (self.selenium.is_text_present('thank') or
+ self.selenium.is_text_present('Thank'))
+
+
+class FooterNewsletterPage(NewsletterPage):
+
+ _form_pane_sel = 'css=#sub-footer .form-pane'
+ _open_button_sel = 'css=#sub-footer a.email-open'
+ _email_sel = "css=#sub-footer .email"
+ _agree_to_privacy_policy_checkbox_sel = "css=#sub-footer .privacy-check"
+ _submit_button_sel = "css=#sub-footer input[name=submit]"
+ _privacy_policy_error_sel = "css=#sub-footer .privacy-field .field-error"
+ _success_pane_sel = "css=#sub-footer .success-pane"
+
+ def go_to_newsletter_page(self):
+ self.selenium.open('/en-US/firefox/features/')
+
+ def click_open_button(self):
+ self.selenium.click(self._open_button_sel)
@property
- def is_thanks_for_subscribing_visible(self):
- return self.is_element_visible(self._success_pane_locator)
+ def is_form_pane_visible(self):
+ return self.selenium.is_visible(self._form_pane_sel)
View
82 test_newsletter.py
@@ -37,27 +37,69 @@
#
# ***** END LICENSE BLOCK *****
from unittestzero import Assert
-from pages.desktop.newsletter import NewsletterPage
-import pytest
-xfail = pytest.mark.xfail
+from pages.desktop.newsletter import (NewsletterPage, MainNewsletterPage,
+ OtherNewsletterPage, FooterNewsletterPage)
class TestNewsletter:
- @xfail(reason="Bug 663528 - Build email preference center on mozilla.com")
- def test_subscribe_to_newsletter_succeeds(self, mozwebqa):
- newsletter_pg = NewsletterPage(mozwebqa)
- newsletter_pg.go_to_newsletter_page()
- newsletter_pg.type_email('me@example.com')
- newsletter_pg.agree_to_privacy_policy()
- newsletter_pg.click_sign_me_up()
- Assert.true(newsletter_pg.is_thanks_for_subscribing_visible)
-
- @xfail(reason="Bug 663528 - Build email preference center on mozilla.com")
- def test_subscribe_to_newsletter_fails_if_user_does_not_agree_to_privacy_policy(self, mozwebqa):
- newsletter_pg = NewsletterPage(mozwebqa)
- newsletter_pg.go_to_newsletter_page()
- newsletter_pg.type_email('me@example.com')
- newsletter_pg.click_sign_me_up()
- Assert.true(newsletter_pg.is_privacy_policy_error_visible)
- Assert.false(newsletter_pg.is_thanks_for_subscribing_visible)
+ def signup_workflow(self, pg):
+ """Submits the form with errors, and then with values that
+ should be a success"""
+
+ pg.click_sign_me_up()
+
+ Assert.true(pg.is_privacy_policy_error_visible)
+ Assert.false(pg.is_success_visible)
+
+ pg.type_email('me@example.com')
+ pg.agree_to_privacy_policy()
+ pg.click_sign_me_up()
+
+ Assert.true(pg.is_success_visible)
+
+ def test_newsletter(self, mozwebqa):
+ pg = MainNewsletterPage(mozwebqa)
+ pg.go_to_newsletter_page()
+ self.signup_workflow(pg)
+
+ def test_other_newsletters(self, mozwebqa):
+ pg = OtherNewsletterPage(mozwebqa)
+ pg.goto_page('me@example.com', 'us', 'en', 'text')
+
+ # Make sure it pre-filled the format correctly
+ Assert.equal(pg.get_email(), 'me@example.com')
+ Assert.equal(pg.get_country(), 'us')
+ Assert.equal(pg.get_lang(), 'en')
+ Assert.equal(pg.get_format(), 'text')
+ Assert.true(pg.is_mozilla_and_you_selected)
+
+ pg.click_submit()
+
+ Assert.false(pg.is_form_visible)
+ Assert.true(pg.is_success_visible)
+
+ def test_newsletter_fr(self, mozwebqa):
+ pg = NewsletterPage(mozwebqa)
+ pg.go_to_newsletter_page('/fr/newsletter/')
+ self.signup_workflow(pg)
+
+ def test_newsletter_de(self, mozwebqa):
+ pg = NewsletterPage(mozwebqa)
+ pg.go_to_newsletter_page('/de/newsletter/')
+ self.signup_workflow(pg)
+
+ def test_newsletter_pt(self, mozwebqa):
+ pg = NewsletterPage(mozwebqa);
+ pg.go_to_newsletter_page('/pt-BR/newsletter/')
+ self.signup_workflow(pg)
+
+ def test_newsletter_footer(self, mozwebqa):
+ pg = FooterNewsletterPage(mozwebqa)
+ pg.go_to_newsletter_page()
+
+ Assert.false(pg.is_form_pane_visible)
+ pg.click_open_button()
+ Assert.true(pg.is_form_pane_visible)
+
+ self.signup_workflow(pg)
Please sign in to comment.
Something went wrong with that request. Please try again.