def test_that_clicking_on_theme_name_loads_its_detail_page(self, testsetup): """test for litmus 15363""" amo_home_page = AddonsHomePage(testsetup) amo_themes_page = amo_home_page.click_themes() addon_name = amo_themes_page.addon_names[0] amo_theme_page = amo_themes_page.click_on_first_addon() Assert.equal(addon_name, amo_theme_page.addon_title)
def test_that_new_review_is_saved(self, testsetup): """ Litmus 22921 https://litmus.mozilla.org/show_test.cgi?id=22921 """ # Step 1 - Login into AMO amo_home_page = AddonsHomePage(testsetup) credentials = amo_home_page.credentials_of_user('default') amo_home_page.header.click_login() addons_login_page = AddonsLoginPage(testsetup) addons_login_page.login(credentials['email'], credentials['password']) Assert.true(amo_home_page.header.is_user_logged_in) # Step 2 - Load any addon detail page details_page = AddonsDetailsPage(testsetup, 'Adblock Plus') # Step 3 - Click on "Write review" button write_review_block = details_page.click_to_write_review() # Step 4 - Write a review body = 'Automatic addon review by Selenium tests' write_review_block.enter_review_with_text(body) write_review_block.set_review_rating(1) review_page = write_review_block.click_to_save_review() # Step 5 - Assert review review = review_page.review() Assert.equal(review.rating, 1) Assert.equal(review.author, credentials['name']) date = datetime.now().strftime("%B %d, %Y") # there are no leading zero-signs on day so we need to remove them too date = date.replace(' 0', ' ') Assert.equal(review.date, date) Assert.equal(review.text, body)
def test_that_clicking_on_theme_name_loads_its_detail_page(self, mozwebqa): """test for litmus 15363""" amo_home_page = AddonsHomePage(mozwebqa) amo_themes_page = amo_home_page.click_themes() addon_name = amo_themes_page.addon_names[0] amo_theme_page = amo_themes_page.click_on_first_addon() Assert.contains(addon_name, amo_theme_page.addon_title)
def test_that_themes_can_be_sorted_by_updated_date(self): """ test for litmus 11750""" amo_home_page = AddonsHomePage(self.selenium) amo_themes_page = amo_home_page.click_themes() amo_themes_page.click_sort_by("updated") addons = amo_themes_page.addon_names addons_set = set(addons) self.assertEquals(len(addons), len(addons_set), "There are duplicates in the names") addon_dates = amo_themes_page.addon_update_dates addons_orig = addon_dates addon_dates.sort() addon_dates.reverse() [ self.assertEqual(addons_orig[i], addon_dates[i]) for i in xrange(len(addons)) ] amo_themes_page.page_forward() addon_dates = amo_themes_page.addon_update_dates addons_orig = addon_dates addon_dates.sort() addon_dates.reverse() [ self.assertEqual(addons_orig[i], addon_dates[i]) for i in xrange(len(addons)) ]
def test_that_clicking_on_a_subcategory_loads_expected_page(self, testsetup): """test for litmus 15949""" amo_home_page = AddonsHomePage(testsetup) amo_themes_page = amo_home_page.click_themes() selected_category = amo_themes_page.themes_category amo_category_page = amo_themes_page.click_on_first_category() Assert.equal(selected_category, amo_category_page.title)
def test_breadcrumb_menu_in_persona_details_page(self, testsetup): """ Test for Litmus 12046 https://litmus.mozilla.org/show_test.cgi?id=12046""" # Step 1, 2: Access AMO Homepage, Click on Persona category link. amo_home_page = AddonsHomePage(testsetup) amo_personas_page = amo_home_page.click_personas() Assert.true(amo_personas_page.is_the_current_page) # Step 3: Click on any persona. random_persona_index = random.randint(1, amo_personas_page.persona_count) print "random_persona_index: %s" % str(random_persona_index) amo_personas_detail_page = amo_personas_page.click_persona(random_persona_index) print "url_current_page: %s" % str(amo_personas_detail_page.get_url_current_page()) Assert.true(amo_personas_detail_page.is_the_current_page) # Verify breadcrumb menu format, i.e. Add-ons for Firefox > Personas > {Persona Name}. persona_title = amo_personas_detail_page.personas_title Assert.equal("Add-ons for Firefox", amo_personas_detail_page.get_breadcrumb_item_text(1)) Assert.equal("Personas", amo_personas_detail_page.get_breadcrumb_item_text(2)) Assert.equal(persona_title, amo_personas_detail_page.get_breadcrumb_item_text(3)) # Step 4: Click on the links present in the Breadcrumb menu. # Verify that the Personas link loads the Personas home page. amo_personas_detail_page.click_breadcrumb_item("Personas") Assert.true(amo_personas_page.is_the_current_page) amo_personas_page.return_to_previous_page() Assert.true(amo_personas_detail_page.is_the_current_page) # Verify that the Add-ons for Firefox link loads the AMO home page. amo_personas_detail_page.click_breadcrumb_item("Add-ons for Firefox") Assert.true(amo_home_page.is_the_current_page)
def test_the_featured_personas_section(self, testsetup): """ Test for Litmus 15392 https://litmus.mozilla.org/show_test.cgi?id=15392""" amo_home_page = AddonsHomePage(testsetup) amo_personas_page = amo_home_page.click_personas() Assert.true(amo_personas_page.is_the_current_page) Assert.equal(6, amo_personas_page.featured_personas_count)
def test_themes_subcategory_page_breadcrumb(self, testsetup): amo_home_page = AddonsHomePage(testsetup) amo_themes_page = amo_home_page.click_themes() selected_category = amo_themes_page.themes_category amo_category_page = amo_themes_page.click_on_first_category() expected_breadcrumb = "Add-ons for Firefox Themes %s" % selected_category Assert.equal(expected_breadcrumb, amo_category_page.breadcrumb)
def test_that_themes_can_be_sorted_by_name(self): """ Test for Litmus 11727, 4839 """ amo_home_page = AddonsHomePage(self.selenium) amo_themes_page = amo_home_page.click_themes() amo_themes_page.click_sort_by("name") addons = amo_themes_page.addon_names addons_set = set(addons) self.assertEquals(len(addons), len(addons_set), "There are duplicates in the names") addons_orig = addons addons.sort() [ self.assertEqual(addons_orig[i], addons[i]) for i in xrange(len(addons)) ] amo_themes_page.page_forward() addons = amo_themes_page.addon_names addons_set = set(addons) self.assertEquals(len(addons), len(addons_set), "There are duplicates in the names") addons_orig = addons addons.sort() [ self.assertEqual(addons_orig[i], addons[i]) for i in xrange(len(addons)) ]
def test_that_character_escaping_doesnt_go_into_the_test(self, testsetup): """ Test for Litmus 4857 https://litmus.mozilla.org/show_test.cgi?id=4857""" amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("personas%20plus") Assert.true(amo_search_page.is_text_present("No results found.")) results_summary = amo_search_page.results_summary Assert.true("0 - 0 of 0" in results_summary)
def test_that_themes_is_listed_as_a_category(self): """ Test for litmus 4839 https://litmus.mozilla.org/show_test.cgi?id=4839 """ amo_home_page = AddonsHomePage(self.selenium) self.assertTrue(amo_home_page.has_category("themes")) amo_home_page.click_category("themes") self.assertTrue(amo_home_page.current_page_is("themes"))
def test_that_entering_a_long_string_returns_no_results(self): """ Litmus 4856 https://litmus.mozilla.org/show_test.cgi?id=4856 """ amo_home_page = AddonsHomePage(self.selenium) amo_search_page = amo_home_page.search_for("a" * 255) self.assertTrue(amo_search_page.is_text_present("No results found.")) results_count = amo_search_page.results_count self.assertTrue("0 - 0 of 0" in results_count)
def test_that_searching_with_numerals_returns_results(self, testsetup): """ Litmus 17347 https://litmus.mozilla.org/show_test.cgi?id=17347 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("1") Assert.true(amo_search_page.result_count > 0)
def test_that_searching_for_cool_returns_cooliris(self, testsetup): """ Litmus 17353 https://litmus.mozilla.org/show_test.cgi?id=17353 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("Cool") Assert.equal(amo_search_page.result(0).name, 'Cooliris')
def test_that_character_escaping_doesnt_go_into_the_test(self): """ Test for Litmus 4857 https://litmus.mozilla.org/show_test.cgi?id=4857""" amo_home_page = AddonsHomePage(self.selenium) amo_search_page = amo_home_page.search_for("personas%20plus") self.assertTrue(amo_search_page.is_text_present("No results found.")) results_count = amo_search_page.results_count self.assertTrue("0 - 0 of 0" in results_count)
def test_that_searching_for_fire_returns_firebug(self, testsetup): """ Litmus 15314 https://litmus.mozilla.org/show_test.cgi?id=15314 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("fire") Assert.equal(amo_search_page.result(0).name, 'Firebug')
def test_that_searching_for_twitter_returns_yoono(self, testsetup): """ Litmus 17354 https://litmus.mozilla.org/show_test.cgi?id=17354 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("twitter") Assert.equal(amo_search_page.result(0).name, 'Yoono: Twitter Facebook LinkedIn YouTube GTalk AIM')
def test_that_verify_the_breadcrumb_on_search_results_page(self, testsetup): """ Litmus 17341 https://litmus.mozilla.org/show_test.cgi?id=17341 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("text") Assert.equal(amo_search_page.breadcrumbs_value, 'Add-ons for Firefox Search')
def test_that_page_with_search_results_has_correct_title(self, testsetup): """ Litmus 17338 https://litmus.mozilla.org/show_test.cgi?id=17338 """ amo_home_page = AddonsHomePage(testsetup) search_keyword = 'Search term' amo_search_page = amo_home_page.search_for(search_keyword) expected_title = 'Add-on Search Results for %s :: Add-ons for Firefox' % search_keyword Assert.equal(expected_title, amo_search_page.page_title)
def test_that_entering_a_long_string_returns_no_results(self, testsetup): """ Litmus 4856 https://litmus.mozilla.org/show_test.cgi?id=4856 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("a" * 255) Assert.true(amo_search_page.is_text_present("No results found.")) results_summary = amo_search_page.results_summary Assert.true("0 - 0 of 0" in results_summary)
def test_that_search_returns_top_1000_results(self, testsetup): amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("a") results = amo_search_page.results_summary total_results = results.split(' ')[5] Assert.equal(total_results, '1000')
def test_that_searching_with_unicode_characters_returns_results(self): """ Litmus 9575 https://litmus.mozilla.org/show_test.cgi?id=9575 """ amo_home_page = AddonsHomePage(self.selenium) search_str = u'\u0421\u043b\u043e\u0432\u0430\u0440\u0438 \u042f\u043d\u0434\u0435\u043a\u0441' amo_search_page = amo_home_page.search_for(search_str) self.assertTrue(amo_search_page.is_text_present(search_str)) results_count = amo_search_page.results_count self.assertFalse("0 - 0 of 0" in results_count)
def test_the_top_rated_section(self, mozwebqa): """ Test for Litmus 15395 https://litmus.mozilla.org/show_test.cgi?id=15395""" amo_home_page = AddonsHomePage(mozwebqa) amo_personas_page = amo_home_page.click_personas() Assert.true(amo_personas_page.is_the_current_page) Assert.equal(6, amo_personas_page.top_rated_count) ratings = amo_personas_page.top_rated_ratings Assert.is_sorted_descending(ratings)
def test_that_blank_search_returns_results(self, testsetup): """ Litmus 11759 https://litmus.mozilla.org/show_test.cgi?id=11759 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("") Assert.false(amo_search_page.is_text_present("Search is currently unavailable")) Assert.false(amo_search_page.is_text_present("No results found.")) results_count = amo_search_page.results_count Assert.false("0 - 0 of 0" in results_count)
def test_that_clicking_mozilla_logo_loads_mozilla_dot_org(self, mozwebqa): """ Litmus 22922 https://litmus.mozilla.org/show_test.cgi?id=22922 """ amo_home_page = AddonsHomePage(mozwebqa) Assert.true(amo_home_page.is_mozilla_logo_visible) amo_home_page.click_mozilla_logo() Assert.equal(amo_home_page.get_url_current_page(), "http://www.mozilla.org/")
def test_the_most_popular_section(self, testsetup): """ Test for Litmus 15394 https://litmus.mozilla.org/show_test.cgi?id=15394""" amo_home_page = AddonsHomePage(testsetup) amo_personas_page = amo_home_page.click_personas() Assert.true(amo_personas_page.is_the_current_page) Assert.equal(6, amo_personas_page.most_popular_count) downloads = amo_personas_page.most_popular_downloads Assert.is_sorted_descending(downloads)
def test_the_recently_added_section(self, testsetup): """ Test for Litmus 15393 https://litmus.mozilla.org/show_test.cgi?id=15393""" amo_home_page = AddonsHomePage(testsetup) amo_personas_page = amo_home_page.click_personas() Assert.true(amo_personas_page.is_the_current_page) Assert.equal(6, amo_personas_page.recently_added_count) recently_added_dates = amo_personas_page.recently_added_dates Assert.is_sorted_descending(recently_added_dates)
def test_that_searching_with_unicode_characters_returns_results(self, testsetup): """ Litmus 9575 https://litmus.mozilla.org/show_test.cgi?id=9575 """ amo_home_page = AddonsHomePage(testsetup) search_str = u'\u0421\u043b\u043e\u0432\u0430\u0440\u0438 \u042f\u043d\u0434\u0435\u043a\u0441' amo_search_page = amo_home_page.search_for(search_str) Assert.true(amo_search_page.is_text_present(search_str)) results_summary = amo_search_page.results_summary Assert.false("0 - 0 of 0" in results_summary)
def test_searching_for_collections_returns_results(self, testsetup): """ Litmus 17352 https://litmus.mozilla.org/show_test.cgi?id=17352 """ amo_home_page = AddonsHomePage(testsetup) amo_collection_page = amo_home_page.click_collections() amo_search_results_page = amo_collection_page.search_for("web") Assert.true(amo_search_results_page.result_count > 0)
def test_that_searching_with_substrings_returns_results(self): """ Litmus 9561 https://litmus.mozilla.org/show_test.cgi?id=9561 """ amo_home_page = AddonsHomePage(self.selenium) amo_search_page = amo_home_page.search_for("fox") self.assertFalse(amo_search_page.is_text_present("No results found.")) results_count = amo_search_page.results_count self.assertFalse("0 - 0 of 0" in results_count) matches = re.search(self._total_count_regex, results_count) self.assertTrue(int(matches.group(1)) > 1)
def test_that_searching_for_a_tag_returns_results(self, testsetup): """ Litmus 7848 https://litmus.mozilla.org/show_test.cgi?id=7848 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("development") Assert.true(amo_search_page.result_count > 0) Assert.equal(amo_search_page.refine_results.tag("development").name, "development") Assert.true(amo_search_page.refine_results.tag_count > 1)
def test_that_searching_with_substrings_returns_results(self, testsetup): """ Litmus 9561 https://litmus.mozilla.org/show_test.cgi?id=9561 """ amo_home_page = AddonsHomePage(testsetup) amo_search_page = amo_home_page.search_for("fox") Assert.false(amo_search_page.is_text_present("No results found.")) results_summary = amo_search_page.results_summary Assert.false("0 - 0 of 0" in results_summary) matches = re.search(self._total_count_regex, results_summary) Assert.true(int(matches.group(1)) > 1)
def test_start_exploring_link_in_the_promo_box(self, testsetup): """ Test for Litmus 12037 https://litmus.mozilla.org/show_test.cgi?id=12037""" amo_home_page = AddonsHomePage(testsetup) amo_personas_page = amo_home_page.click_personas() Assert.true(amo_personas_page.is_the_current_page) Assert.true(amo_personas_page.is_featured_addons_present) browse_personas_page = amo_personas_page.click_start_exploring() Assert.true(browse_personas_page.is_the_current_page) Assert.equal("up-and-coming", browse_personas_page.sort_key) Assert.equal("Up & Coming", browse_personas_page.sort_by)
def test_other_applications_thunderbird(self, testsetup): """ Test for litmus 5037 https://litmus.mozilla.org/show_test.cgi?id=5037 """ amo_home_page = AddonsHomePage(testsetup) amo_home_page.header.click_other_applications() amo_home_page.header.click_thunderbird() Assert.true("thunderbird" in amo_home_page.get_url_current_page()) amo_home_page.header.click_other_applications() Assert.false(amo_home_page.header.is_thunderbird_visible())
def test_that_themes_can_be_sorted_by_created_date(self, testsetup): """ test for litmus 11638 """ amo_home_page = AddonsHomePage(testsetup) amo_themes_page = amo_home_page.click_themes() amo_themes_page.click_sort_by("created") addons = amo_themes_page.addon_names addons_set = set(addons) Assert.equal(len(addons), len(addons_set), "There are duplicates in the names") created_dates = amo_themes_page.addon_created_dates Assert.is_sorted_descending(created_dates) amo_themes_page.page_forward() created_dates.extend(amo_themes_page.addon_created_dates) Assert.is_sorted_descending(created_dates)
def test_that_addons_count_are_equal_between_amo_and_discovery(self): """ TestCase for Litmus 15066 """ amo_home_page = AddonsHomePage(self.selenium) amo_download_count = amo_home_page.download_count.replace(",","") discovery_pane = DiscoveryPane(self.selenium, self.basepath) discovery_download_count_text = discovery_pane.download_count download_count = re.search("Add-ons downloaded: (.+)", discovery_download_count_text).group(1) download_count = download_count.replace(",","") self.assertEquals(amo_download_count, download_count)
def test_that_search_all_add_ons_results_have_pagination_that_moves_through_results( self): """ Test for litmus 4839 https://litmus.mozilla.org/show_test.cgi?id=4839 """ amo_home_page = AddonsHomePage(self.selenium) amo_search_page = amo_home_page.search_for("addon") first_expected = 1 second_expected = 20 # Go Forward 10 times for i in range(10): amo_search_page.page_forward() results_count = amo_search_page.results_count matches = re.search(self._count_regex, results_count) first_count = matches.group(1) second_count = matches.group(2) first_expected += 20 second_expected += 20 self.assertEqual(str(first_expected), first_count) self.assertEqual(str(second_expected), second_count) # Go Back 10 Times for i in range(10): amo_search_page.page_back() results_count = amo_search_page.results_count matches = re.search(self._count_regex, results_count) first_count = matches.group(1) second_count = matches.group(2) first_expected -= 20 second_expected -= 20 self.assertEqual(str(first_expected), first_count) self.assertEqual(str(second_expected), second_count)
def test_navigate_to_detail_page_from_addon_search_page(self, testsetup): home_page = AddonsHomePage(testsetup) search_page = home_page.search_for("Firebug") detail_page = search_page.click_addon("Firebug") Assert.equal("Firebug :: Add-ons for Firefox", detail_page.page_title)
def test_type_method_and_AddonHomePage(self): addon_search_page = AddonsHomePage(self.selenium) self.selenium.type("name=q", "Pixlr Grabber")