This repository has been archived by the owner on Jan 31, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bug 1021155] Add basic FirefoxOS smoketest
This is a basic FirefoxOS smoketest to make sure we can post and that at least some of the information is making it. This adds a bunch of FIXME items for additional tests we could/should add to have parity with the generic form smoketest.
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/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 pages.base import Page | ||
|
||
|
||
class FxOSFeedbackFormPage(Page): | ||
_page_title = 'Submit Your Feedback :: Firefox Input' | ||
|
||
def go_to_feedback_page(self): | ||
self.selenium.get(self.base_url + '/feedback/fxos/') | ||
self.is_the_current_page | ||
|
||
# Intro card | ||
_happy_button_locator = (By.CSS_SELECTOR, '#intro button.happy') | ||
_sad_button_locator = (By.CSS_SELECTOR, '#intro button.sad') | ||
|
||
def click_happy_feedback(self): | ||
self.selenium.find_element(*self._happy_button_locator).click() | ||
self.wait_for(self._country_select_locator) | ||
|
||
def click_sad_feedback(self): | ||
self.selenium.find_element(*self._sad_button_locator).click() | ||
self.wait_for(self._country_select_locator) | ||
|
||
# Country selection card | ||
_country_select_locator = (By.CSS_SELECTOR, '#country select') | ||
_country_next_locator = (By.CSS_SELECTOR, '#country button.next') | ||
|
||
def click_country_next(self): | ||
self.selenium.find_element(*self._country_next_locator).click() | ||
self.wait_for(self._device_select_locator) | ||
|
||
# Device selection card | ||
_device_select_locator = (By.CSS_SELECTOR, '#device select') | ||
_device_next_locator = (By.CSS_SELECTOR, '#device button.next') | ||
|
||
def click_device_next(self): | ||
self.selenium.find_element(*self._device_next_locator).click() | ||
self.wait_for(self._moreinfo_text_locator) | ||
|
||
# Description card | ||
_moreinfo_text_locator = (By.CSS_SELECTOR, '#moreinfo #description') | ||
_moreinfo_next_locator = (By.CSS_SELECTOR, '#moreinfo button.next') | ||
|
||
def set_description_execute_script(self, text): | ||
"""Sets the value of the description textarea using execute_script | ||
:arg text: The text to set | ||
We use ``execute_script`` here because sending keys one at a time | ||
takes a crazy amount of time for texts > 200 characters. | ||
""" | ||
text = text.replace("'", "\\'").replace('"', '\\"') | ||
self.selenium.execute_script("$('#description').val('" + text + "')") | ||
|
||
def set_description(self, text): | ||
desc = self.selenium.find_element(*self._moreinfo_text_locator) | ||
desc.clear() | ||
desc.send_keys(text) | ||
|
||
def update_description(self, text): | ||
desc = self.selenium.find_element(*self._moreinfo_text_locator) | ||
desc.send_keys(text) | ||
|
||
@property | ||
def is_moreinfo_next_enabled(self): | ||
return self.selenium.find_element(*self._moreinfo_next_locator).is_enabled() | ||
|
||
def click_moreinfo_next(self): | ||
self.selenium.find_element(*self._device_next_locator).click() | ||
self.wait_for(self._email_checkbox_locator) | ||
|
||
# Email card | ||
_email_checkbox_locator = (By.CSS_SELECTOR, '#email input#email-ok') | ||
_email_text_locator = (By.CSS_SELECTOR, '#email input#email-input') | ||
_submit_locator = (By.CSS_SELECTOR, '#email button.submit') | ||
_thanks_locator = (By.CSS_SELECTOR, '#thanks') | ||
|
||
def check_email_checkbox(self, checked=True): | ||
checkbox = self.selenium.find_element(*self._email_checkbox_locator) | ||
if checked != checkbox.is_selected(): | ||
checkbox.click() | ||
|
||
def set_email(self, text): | ||
email = self.selenium.find_element(*self._email_text_locator) | ||
email.clear() | ||
email.send_keys(text) | ||
|
||
def submit(self, expect_success=True): | ||
self.selenium.find_element(*self._submit_locator).click() | ||
if expect_success: | ||
self.wait_for(self._thanks_locator) | ||
|
||
@property | ||
def current_card(self): | ||
for card in ('intro', 'country', 'device', 'moreinfo', 'email', | ||
'submitting', 'thanks', 'failure', 'tryagain'): | ||
|
||
if self.is_element_visible_no_wait((By.CSS_SELECTOR, '#' + card)): | ||
return card |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 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 unittestzero import Assert | ||
|
||
from pages.dashboard import DashboardPage | ||
from pages.fxos_feedback_form import FxOSFeedbackFormPage | ||
|
||
|
||
class TestFeedback(object): | ||
def test_submit_happy_feedback(self, mozwebqa): | ||
timestamp = str(time.time()) | ||
desc = 'input-tests testing happy fxos feedback ' + timestamp | ||
|
||
# 1. go to the feedback form | ||
feedback_pg = FxOSFeedbackFormPage(mozwebqa) | ||
feedback_pg.go_to_feedback_page() | ||
|
||
# 2. click on happy | ||
feedback_pg.click_happy_feedback() | ||
|
||
# 3. pick default country | ||
feedback_pg.click_country_next() | ||
|
||
# 4. pick default device | ||
feedback_pg.click_device_next() | ||
|
||
# 5. fill in description | ||
Assert.false(feedback_pg.is_moreinfo_next_enabled) | ||
feedback_pg.set_description(desc) | ||
Assert.true(feedback_pg.is_moreinfo_next_enabled) | ||
feedback_pg.click_moreinfo_next() | ||
|
||
# 6. fill in email address | ||
feedback_pg.check_email_checkbox() | ||
feedback_pg.set_email('foo@example.com') | ||
|
||
# 7. submit | ||
feedback_pg.submit(expect_success=True) | ||
Assert.equal(feedback_pg.current_card, 'thanks') | ||
|
||
# 8. verify | ||
dashboard_pg = DashboardPage(mozwebqa) | ||
dashboard_pg.go_to_dashboard_page() | ||
dashboard_pg.search_for(desc) | ||
resp = dashboard_pg.messages[0] | ||
Assert.equal(resp.type.strip(), 'Happy') | ||
Assert.equal(resp.body.strip(), desc.strip()) | ||
Assert.equal(resp.locale.strip(), 'English (US)') | ||
|
||
# FIXME: Test sad submit | ||
|
||
# FIXME: Test back and forth | ||
|
||
# FIXME: Test happy submit with unicode | ||
|
||
# FIXME: Test character counter | ||
|
||
# FIXME: Test email verification |