def test_feedback_custom_date_filter_with_bad_dates(self, mozwebqa): """Verify random non-dates are ignored""" dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() start_date = random.randint(10000000, 50000000) end_date = random.randint(50000001, 99999999) def build_random_date(start, end): dte = random.randint(start, end) dte = str(dte) return '-'.join([dte[0:4], dte[4:6], dte[6:8]]) data = [ (build_random_date(10000000, 15000000), build_random_date(90000001, 99999999)), ('0000-00-00', '0000-00-00'), ] for start_date, end_date in data: dashboard_pg.date_filter.filter_by_custom_dates_using_keyboard( start_date, end_date) assert dashboard_pg.date_start_from_url == str(start_date) assert dashboard_pg.date_end_from_url == str(end_date) assert len(dashboard_pg.messages) == 20 dashboard_pg.date_filter.enable_custom_dates() assert dashboard_pg.date_filter.custom_start_date == self.default_start_date assert dashboard_pg.date_filter.custom_end_date == self.default_end_date
def test_submit_sad_feedback(self, mozwebqa): timestamp = str(time.time()) desc = 'input-tests testing sad feedback ' + timestamp url = 'http://sad.example.com/' + timestamp # 1. go to the feedback form feedback_pg = GenericFeedbackFormPage(mozwebqa) feedback_pg.go_to_feedback_page('firefox') # 2. click on sad feedback_pg.click_sad_feedback() # 3. fill out description, url, email checkbox and email # address feedback_pg.set_description(desc) feedback_pg.set_url(url) feedback_pg.check_email_checkbox() feedback_pg.set_email('*****@*****.**') # 4. submit thanks_pg = feedback_pg.submit(expect_success=True) Assert.true(thanks_pg.is_the_current_page) # 5. 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(), 'Sad') Assert.equal(resp.body.strip(), desc.strip()) Assert.equal(resp.locale.strip(), 'English (US)') Assert.equal(resp.site.strip(), 'example.com')
def test_submit_sad_feedback(self, mozwebqa): timestamp = str(time.time()) desc = 'input-tests testing sad 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_sad_feedback() # 3. pick default country feedback_pg.click_country_next() # 4. pick default device feedback_pg.click_device_next() # 5. fill in description feedback_pg.set_description(desc) # 6. submit feedback_pg.submit(expect_success=True) self.take_a_breather() assert feedback_pg.current_card == 'thanks' # 7. verify dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() dashboard_pg.search_for(desc) resp = dashboard_pg.messages[0] assert resp.type.strip() == 'Sad' assert resp.body.strip() == desc.strip() assert resp.locale.strip() == 'English (US)'
def test_feedback_custom_date_filter_with_end_date_lower_than_start_date( self, mozwebqa): """Verify start_date > end_date get switched automatically and the results are shown from end date to start date """ dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() start_date = date.today() - timedelta(days=1) end_date = date.today() - timedelta(days=3) dashboard_pg.date_filter.filter_by_custom_dates_using_datepicker( start_date, end_date) assert dashboard_pg.date_start_from_url == start_date.strftime( '%Y-%m-%d') assert dashboard_pg.date_end_from_url == end_date.strftime('%Y-%m-%d') # TODO: Check results are within the expected date range, # possibly by navigating to the first/last pages and checking # the final result is within range. Currently blocked by bug # 615844. # Test that the dates in the date filter are reordered chronologically dashboard_pg.date_filter.enable_custom_dates() assert dashboard_pg.date_filter.custom_start_date == end_date.strftime( '%Y-%m-%d') assert dashboard_pg.date_filter.custom_end_date == start_date.strftime( '%Y-%m-%d')
def test_submit_happy_feedback_with_unicode(self, mozwebqa): """Fill out happy feedback with unicode description""" timestamp = unicode(time.time()) desc = u'input-tests testing happy feedback with unicode \u2603' desc = desc + u' ' + timestamp # 1. go to the feedback form feedback_pg = GenericFeedbackFormPage(mozwebqa) feedback_pg.go_to_feedback_page('firefox') # 2. click on happy feedback_pg.click_happy_feedback() # 3. fill out description and url feedback_pg.set_description(desc) # 4. submit thanks_pg = feedback_pg.submit(expect_success=True) Assert.true(thanks_pg.is_the_current_page) # 5. 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())
def test_dashboard(base_url, selenium): page = DashboardPage(selenium, base_url).open() first_row = page.first_row # ip toggle not present assert not page.is_ip_toggle_present # ip ban not present assert not first_row.is_ip_ban_present # spam ham button not present assert not first_row.is_spam_ham_button_present # no dashboard-details assert page.details_items_length is 0 # click first cell page.open_first_details() # dashboard-details exist and are visible assert page.details_items_length is 1 assert page.is_first_details_displayed # contains a diff assert page.is_first_details_diff_displayed # save id of first revision on page one first_row_id = page.first_row_id # click on page two link page.click_page_two() # save id of first revision on page tw0 new_first_row_id = page.first_row_id # check first revison on page one is not on page two assert first_row_id is not new_first_row_id
def test_search_pagination(self, mozwebqa): dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() # Set the date range to 2013-01-01 -> today so that we're more # likely to have so many messages in the results that it # paginates. Otherwise it might not paginate on stage or local # environments. dashboard_pg.set_date_range('2013-01-01') dashboard_pg.search_for(self.SEARCH_TERM) # Check the total message count. If it's less than 50 (two # pages worth), then we will fail with a helpful message. assert dashboard_pg.total_message_count >= 50, 'Not enough data to test. Add more data.' assert dashboard_pg.is_older_messages_link_visible is True assert dashboard_pg.is_newer_messages_link_visible is False assert dashboard_pg.older_messages_link == 'Older Messages' dashboard_pg.click_older_messages() assert dashboard_pg.search_term_from_url == self.SEARCH_TERM assert dashboard_pg.is_older_messages_link_visible is True assert dashboard_pg.is_newer_messages_link_visible is True assert dashboard_pg.older_messages_link == 'Older Messages' assert dashboard_pg.newer_messages_link == 'Newer Messages' assert dashboard_pg.page_from_url == 2 dashboard_pg.click_newer_messages() assert dashboard_pg.search_term_from_url == self.SEARCH_TERM assert dashboard_pg.is_older_messages_link_visible is True assert dashboard_pg.is_newer_messages_link_visible is False assert dashboard_pg.older_messages_link == 'Older Messages' assert dashboard_pg.page_from_url == 1
def test_submit_sad_feedback_using_prefill(self, mozwebqa): timestamp = str(time.time()) desc = 'input-tests testing sad feedback ' + timestamp # 1. go to the feedback form with sad prefill feedback_pg = GenericFeedbackFormPage(mozwebqa) feedback_pg.go_to_feedback_page( 'firefox', querystring='happy=0&url=http%3A%2F%2Fwww.mozilla.org') # 2. fill out description feedback_pg.set_description(desc) # 3. submit thanks_pg = feedback_pg.submit(expect_success=True) assert thanks_pg.is_the_current_page # 4. verify dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() dashboard_pg.search_for(desc) resp = dashboard_pg.messages[0] assert resp.type.strip() == 'Sad' assert resp.url.strip() == 'http://www.mozilla.org' assert resp.body.strip() == desc.strip() assert resp.locale.strip() == 'English (US)'
def _do_login(self, continue_function, user='******', force_dashboard=True): self._set_login_fields(user) # TODO: Remove once bug is fixed time.sleep(1.25) continue_function() try: self._wait_for_results_refresh() except: self._wait_for_results_refresh() from pages.dashboard import DashboardPage page = DashboardPage(self.testsetup) try: page.is_the_current_page except AssertionError: if force_dashboard: from fixtures.navigation import intel_dashboard_pg page = intel_dashboard_pg() else: # Not the dashboard page and not forcing dashboard page # return a generic Base page page = Base(self.testsetup) return page
def test_feedback_custom_date_filter(self, mozwebqa): """ 1. Verifies the calendar is displayed when filtering on custom dates 2. Verifies date-start=<date> and end-date=<date> in the url """ dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() start_date = date.today() - timedelta(days=3) end_date = date.today() - timedelta(days=1) dashboard_pg.date_filter.filter_by_custom_dates_using_datepicker( start_date, end_date) assert dashboard_pg.date_start_from_url == start_date.strftime( '%Y-%m-%d') assert dashboard_pg.date_end_from_url == end_date.strftime('%Y-%m-%d') # TODO: Check results are within the expected date range, # possibly by navigating to the first/last pages and checking # the final result is within range. Currently blocked by bug # 615844. day_filters = ((1, "1d"), (7, "7d"), (30, "30d")) for days in day_filters: start_date = date.today() - timedelta(days=days[0]) dashboard_pg.date_filter.filter_by_custom_dates_using_datepicker( start_date, date.today()) assert dashboard_pg.date_filter.is_custom_date_filter_visible is False assert dashboard_pg.date_start_from_url == start_date.strftime( '%Y-%m-%d') assert dashboard_pg.date_end_from_url == self.default_end_date
def test_that_we_can_search_feedback_with_unicode(self, mozwebqa): dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() dashboard_pg.search_for(u"p\xe1gina") # There's no way to guarantee that the search we did finds # responses on the page. So we check for one of two possible # scenarios: existences of responses or a message count of 0. assert dashboard_pg.no_messages or (len(dashboard_pg.messages) > 0)
def test_dashboard_overflow(base_url, selenium): """ The revision detail diff stays in page boundaries bug 1405690 - some content causes overflows """ page = DashboardPage(selenium, base_url).open() page.open_first_details() assert page.scrollWidth < page.clientWidth
def test_dashboard_load_page_two(base_url, selenium): page = DashboardPage(selenium, base_url).open() # save id of first revision on page one first_row_id = page.first_row_id # click on page two link page.click_page_two() # save id of first revision on page tw0 new_first_row_id = page.first_row_id # check first revison on page one is not on page two assert first_row_id is not new_first_row_id
def test_submitting_same_feedback_twice(self, mozwebqa): """Submitting the same feedback twice ignores the second""" timestamp = str(time.time()) desc = 'input-tests testing repeat feedback ' + timestamp # Submit the feedback the first time feedback_pg = GenericFeedbackFormPage(mozwebqa) feedback_pg.go_to_feedback_page('firefox') feedback_pg.click_happy_feedback() feedback_pg.set_description(desc) thanks_pg = feedback_pg.submit(expect_success=True) Assert.true(thanks_pg.is_the_current_page) dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() dashboard_pg.search_for(desc) resp = dashboard_pg.messages[0] Assert.equal(resp.body.strip(), desc.strip()) first_id = resp.response_id.strip() # Submit it a second time--we get the Thank You page again and # it looks identical to the first time. feedback_pg = GenericFeedbackFormPage(mozwebqa) feedback_pg.go_to_feedback_page('firefox') feedback_pg.click_happy_feedback() feedback_pg.set_description(desc) thanks_pg = feedback_pg.submit(expect_success=True) Assert.true(thanks_pg.is_the_current_page) # Check the dashboard again and make sure the most recent # response has the same created time as the first time. If it # does, then dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() dashboard_pg.search_for(desc) resp = dashboard_pg.messages[0] Assert.equal(resp.body.strip(), desc.strip()) second_id = resp.response_id.strip() # The two ids should be the same because the second response # didn't go through. Assert.equal(first_id, second_id)
def test_dashboard_open_details(base_url, selenium): page = DashboardPage(selenium, base_url).open() # no dashboard-details assert page.details_items_length is 0 # click first cell page.open_first_details() # dashboard-details exist and are visible assert page.details_items_length is 1 assert page.is_first_details_displayed # contains a diff page.wait_for_first_details_diff_displayed()
def test_dashboard(base_url, selenium): page = DashboardPage(selenium, base_url).open() first_row = page.first_row # ip toggle not present assert not page.is_ip_toggle_present # ip ban not present assert not first_row.is_ip_ban_present # spam ham button not present assert not first_row.is_spam_ham_button_present # no dashboard-details assert page.details_items_length is 0
def __do_login(self, continue_function, user='******'): self.__set_login_fields(user) # TODO: Remove once bug is fixed time.sleep(1.25) continue_function() try: self._wait_for_results_refresh() except: self._wait_for_results_refresh() from pages.dashboard import DashboardPage return DashboardPage(self.testsetup)
def testing_with_correct_data(browser, user_name, pass_word): login_page = LoginPage(browser) login_page.load(url=data.LOGIN_URL) login_page.fill_username(user_name) login_page.fill_password(pass_word) login_page.click_login() dashboard_page = DashboardPage(browser) title_has_part = dashboard_page.check_title() assert title_has_part is True
def test_dashboard_super(base_url, selenium): admin = AdminLogin(selenium, base_url).open() admin.login_super_user() page = DashboardPage(selenium, base_url).open() first_row = page.first_row # ip toggle present assert page.is_ip_toggle_present # ip ban present assert first_row.is_ip_ban_present # spam ham button present assert first_row.is_spam_ham_button_present
def test_dashboard_overflow(base_url, selenium): """ The revision detail diff stays in page boundaries bug 1405690 - some content causes overflows """ admin = AdminLogin(selenium, base_url).open() admin.login_new_user() page = DashboardPage(selenium, base_url).open() page.open_first_details() assert page.scroll_width <= page.client_width
def test_dashboard_open_details(base_url, selenium): admin = AdminLogin(selenium, base_url).open() admin.login_new_user() page = DashboardPage(selenium, base_url).open() # no dashboard-details assert page.details_items_length == 0 # click first cell page.open_first_details() # dashboard-details exist and are visible assert page.details_items_length == 1 assert page.is_first_details_displayed # contains a diff page.wait_for_first_details_diff_displayed()
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() # Verify there is a privacy link feedback_pg.has_privacy_link # 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 feedback_pg.has_privacy_link assert feedback_pg.is_submit_enabled is False feedback_pg.set_description(desc) assert feedback_pg.is_submit_enabled is True # 6. fill in url feedback_pg.set_url('http://example.com/foo') # 7. fill in email address # FIXME: check email input disabled feedback_pg.check_email_checkbox() # FIXME: check email input enabled feedback_pg.set_email('*****@*****.**') # 8. submit feedback_pg.submit(expect_success=True) self.take_a_breather() assert feedback_pg.current_card == 'thanks' # 9. verify dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() dashboard_pg.search_for(desc) resp = dashboard_pg.messages[0] assert resp.type.strip() == 'Happy' assert resp.body.strip() == desc.strip() assert resp.locale.strip() == 'English (US)'
def test_feedback_can_be_filtered_by_all_products_and_versions(self, mozwebqa): """Tests product filtering in dashboard 1. Verify that at least one product exists 2. Verify that filtering by product returns results 3. Verify that versions show up when you choose a product 4. Verify that the state of the filters are correct after being applied 5. Verify product and version values in the URL NB: We don't cycle through all product/version combinations--only the first two of each. """ dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() total_messages = dashboard_pg.total_message_count products = dashboard_pg.product_filter.products Assert.greater(len(products), 0) for product in products[:2]: if not product: # If it's the "unknown" product, just skip it. continue dashboard_pg.product_filter.select_product(product) Assert.greater(total_messages, dashboard_pg.total_message_count) versions = dashboard_pg.product_filter.versions Assert.greater(len(versions), 0) for version in versions[:2]: if not version: # If it's the "unknown" version, just skip it. continue dashboard_pg.product_filter.select_version(version) Assert.greater(total_messages, dashboard_pg.total_message_count) Assert.equal(dashboard_pg.product_filter.selected_product, product) Assert.equal(dashboard_pg.product_filter.selected_version, version) Assert.equal(dashboard_pg.product_from_url, product) Assert.equal(dashboard_pg.version_from_url, version) Assert.greater(len(dashboard_pg.messages), 0) dashboard_pg.product_filter.unselect_version(version) dashboard_pg.product_filter.unselect_product(product)
def start_page(browser): login_page = LoginPage(browser) login_page.load(url=data.LOGIN_URL) login_page.fill_username(data.LOGIN_EMAIL) login_page.fill_password(data.LOGIN_PASSWORD) login_page.click_login() time.sleep(3) dashboard_page = DashboardPage(browser) dashboard_page.click_staff() time.sleep(3) staff_page = StaffPage(browser) staff_page.click_add_employee() time.sleep(3) add_employees_page = AddEmployeesPage(browser) return add_employees_page
def __do_login(self, continue_function, user='******'): self.__set_login_fields(user) # TODO: Remove once bug is fixed time.sleep(1.25) continue_function() try: self._wait_for_results_refresh() except: self._wait_for_results_refresh() from pages.dashboard import DashboardPage dashboard = DashboardPage(self.testsetup) try: dashboard.is_the_current_page except AssertionError: from fixtures.navigation import intel_dashboard_pg dashboard = intel_dashboard_pg(dashboard) return dashboard
def test_feedback_custom_date_filter_future_dates(self, mozwebqa): dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() start_date = "2021-01-01" end_date = "2031-01-01" dashboard_pg.date_filter.filter_by_custom_dates_using_keyboard( start_date, end_date) assert dashboard_pg.date_start_from_url == start_date assert dashboard_pg.date_end_from_url == end_date assert dashboard_pg.no_messages is True assert dashboard_pg.no_messages_message == 'No feedback matches that criteria.' dashboard_pg.date_filter.enable_custom_dates() assert dashboard_pg.date_filter.custom_start_date == start_date assert dashboard_pg.date_filter.custom_end_date == end_date
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() self.take_a_breather() # 6. fill in email address feedback_pg.check_email_checkbox() feedback_pg.set_email('*****@*****.**') # 7. submit feedback_pg.submit(expect_success=True) self.take_a_breather() 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)')
def test_feedback_custom_date_filter_future_dates(self, mozwebqa): dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() start_date = "2021-01-01" end_date = "2031-01-01" dashboard_pg.date_filter.filter_by_custom_dates_using_keyboard( start_date, end_date) Assert.equal(dashboard_pg.date_start_from_url, start_date) Assert.equal(dashboard_pg.date_end_from_url, end_date) Assert.true(dashboard_pg.no_messages) Assert.equal(dashboard_pg.no_messages_message, 'No feedback matches that criteria.') dashboard_pg.date_filter.enable_custom_dates() Assert.equal(dashboard_pg.date_filter.custom_start_date, start_date) Assert.equal(dashboard_pg.date_filter.custom_end_date, end_date)
def test_feedback_custom_date_filter_with_random_alphabet(self, mozwebqa): """Verify custom date fields do not accept alphabet""" # FIXME: If the server is in a different time zone than the # machine running this test, then "today" could be different # than the server default and thus this test will fail. dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() letters = 'abcdefghijklmnopqrstuvwxyz' start_date = ''.join(random.sample(letters, 8)) end_date = ''.join(random.sample(letters, 8)) dashboard_pg.date_filter.filter_by_custom_dates_using_keyboard( start_date, end_date) assert dashboard_pg.date_start_from_url == '' assert dashboard_pg.date_end_from_url == '' dashboard_pg.date_filter.enable_custom_dates() assert dashboard_pg.date_filter.custom_start_date == self.default_start_date assert dashboard_pg.date_filter.custom_end_date == self.default_end_date
def test_feedback_can_be_filtered_by_locale(self, mozwebqa): """Tests locale filtering in dashboard 1. Verify we see at least one locale 2. Select that locale 3. Verify number of messages in locale is less than total number of messages 4. Verify locale short code appears in the URL 5. Verify that the locale for all messages on the first page of results is correct """ dashboard_pg = DashboardPage(mozwebqa) dashboard_pg.go_to_dashboard_page() total_messages = dashboard_pg.total_message_count locales = dashboard_pg.locale_filter.locales locale_names = [locale.name for locale in locales] Assert.greater_equal(len(locales), 1) for name in locale_names[:2]: locale = dashboard_pg.locale_filter.locale(name) locale_name = locale.name locale_code = locale.code locale_count = locale.message_count Assert.greater(total_messages, locale_count) dashboard_pg.locale_filter.select_locale(locale_code) Assert.greater(total_messages, dashboard_pg.total_message_count) Assert.equal(len(dashboard_pg.locale_filter.locales), 1) Assert.equal(dashboard_pg.locale_filter.selected_locale.name, locale_name) Assert.equal(dashboard_pg.locale_from_url, locale_code) for message in dashboard_pg.messages: Assert.equal(message.locale, locale_name) dashboard_pg.locale_filter.unselect_locale(locale_code)