def test_more_info_addon_tags(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() # get the name of one of the tags related to this addon tag_name = addon.more_info.addon_tags[0].text addon.more_info.addon_tags[0].click() # clicking on the tag opens a search results page with addons that share the same tag same_tag_results = Search(selenium, base_url).wait_for_page_to_load() # verifies that the results URL mention the tag name (encoded) assert f'/tag/{urllib.parse.quote(tag_name)}/' in selenium.current_url count = 0 # checking that the first 5 search results do include the tag of the initial addon while count < 5: try: same_tag_results.result_list.click_search_result(count) # the 'click_search_result' function should already wait for the detail page to load # but I also want to check that the page switch occurred; helps with debugging test failures addon.wait_for_current_url('firefox/addon/') tag_name_from_search = [ el.text for el in addon.more_info.addon_tags ] assert tag_name in tag_name_from_search, f'for {addon.name}' selenium.back() same_tag_results.search_results_list_loaded(5) except IndexError: print('There were less than 5 results matching the selected tag') break count += 1
def test_create_collection_from_addon_detail_page(selenium, base_url, variables, wait): extension = variables['non_recommended_addon'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('collection_user') addon_name = addon.name select = Select(addon.add_to_collection.collections_select_field) # start the collection crete process from the addon detail page # which will automatically include the addon to the new collection select.select_by_visible_text('Create new collection') collections = Collections(selenium, base_url).wait_for_page_to_load() # fill up the collection creation form opened name = reusables.get_random_string(15) collections.create.set_name(name) collections.create.save_collection() # waits for the collection detail to be loaded after saving wait.until(lambda _: len(collections.create.edit_addons_list) > 0) collection_addon = collections.create.edit_addons_list[ 0].edit_list_addon_name # verify that the addon was indeed added to the collection assert addon_name == collection_addon # deleting the collection to avoid having too many collections for this test user collections.collection_detail.delete_collection() collections.collection_detail.confirm_delete_collection()
def link(self): self.wait.until( EC.element_to_be_clickable(self._search_item_name_locator)) self.find_element(*self._search_item_name_locator).click() from pages.desktop.frontend.details import Detail detail_page = Detail(self.selenium, self.page.page.base_url) return detail_page.wait_for_page_to_load()
def test_addon_detail_by_firefox_badge(selenium, base_url, variables): extension = variables['by_firefox_addon'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url) assert addon.promoted_badge.is_displayed() assert 'By Firefox' in addon.promoted_badge_category # checks that the badge redirects to the correct sumo article addon.click_promoted_badge() assert 'add-on-badges' in selenium.current_url
def test_link_to_all_reviews(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') reviews_link_count = addon.ratings.all_reviews_link_rating_count # click on the ratings card link to open the All Reviews page reviews = addon.ratings.click_all_reviews_link() # check that the ratings card review counts and All Reviews counts are matching assert reviews_link_count == reviews.reviews_title_count
def test_edit_star_rating(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') # checks the rating score before selecting a different star rating assert len(addon.ratings.selected_star_highlight) == 5 addon.ratings.rating_stars[3].click() # verifies that the new score is reflected by the number of highlighted stars assert len(addon.ratings.selected_star_highlight) == 4
def test_cancel_delete_review(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') addon.ratings.delete_review.click() # opt for the option to keep the review instead confirming to delete it # and verify that the review body is still displayed after that addon.ratings.keep_review_button.click() assert addon.ratings.written_review.is_displayed()
def test_click_addon_recommendations(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() recommendation_name = addon.recommendations.recommendations_results_item[ 0].text # clicks on a recommendations and checks that the addon detail page is loaded addon.recommendations.recommendations_results_item[0].click() addon.wait_for_page_to_load() assert recommendation_name in addon.name
def test_user_review_permalink(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') # click on the review permalink (post date) and check that the All reviews page opens # with the posted user review on top (i.e. the user display name is in the All Reviews page title) addon.ratings.review_permalink.click() reviews = Reviews(selenium, base_url).wait_for_page_to_load() assert 'rating_user' in reviews.user_review_permalink
def test_higher_firefox_incompatibility(selenium, base_url, variables): extension = variables['higher_firefox_version'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() assert ('You need an updated version of Firefox for this extension' in addon.compatibility_banner.text) assert 'Download Firefox' in addon.get_firefox_button.text # clicks on the Download button and checks that the download Firefox page opens addon.get_firefox_button.click() addon.wait_for_current_url('/firefox/download/thanks/')
def test_click_addon_in_more_addons_by_author(selenium, base_url, variables): extension = variables['experimental_addon'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() result_name = addon.same_author_addons.addons_by_author_results_items[ 0].text # clicks on an addon present in the card and checks that the addon detail page is loaded addon.same_author_addons.addons_by_author_results_items[0].click() addon.wait_for_page_to_load() assert result_name in addon.name
def test_more_info_support_links(selenium, base_url, variables, count, link): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() assert link in addon.more_info.addon_support_links[count].text # excluding 'Support Email' since it doesn't open a new page when # clicked; this is a mailto link which is not handled by the browser if count != 2: addon.more_info.addon_support_links[count].click() # opens the homepage/support page provided by the developer addon.wait_for_current_url(variables['support_site_link'])
def test_cancel_edit_review(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') addon.ratings.edit_review.click() # cancel the edit review from and check that the form is no longer displayed addon.ratings.cancel_review.click() with pytest.raises(NoSuchElementException): selenium.find_element_by_css_selector( '.AddonReviewManager .DismissibleTextForm-dismiss')
def test_edit_review(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') addon.ratings.edit_review.click() edited_review_text = variables['edited_text_input'] addon.ratings.review_text_input(edited_review_text) # updates the review text and verifies that the changes are saved addon.ratings.submit_review() assert edited_review_text in addon.ratings.written_review.text
def test_edit_developer_reply_to_review(selenium, base_url, variables): extension = variables['dev_reply_review'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('developer') reviews = addon.ratings.click_all_reviews_link() edited_reply = variables['edited_text_input'] addon.ratings.edit_review.click() reviews.review_items[0].reply_text_input(edited_reply) reviews.review_items[0].publish_reply() assert edited_reply in reviews.review_items[0].posted_reply_text
def test_select_result_with_enter_key(base_url, selenium, variables): page = Home(selenium, base_url).open() term = variables['search_term'] page.search.search_for(term, execute=False) action = ActionChains(selenium) action.send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # give time to the detail page to load page.wait_for_title_update(term) detail = Detail(selenium, base_url) detail.wait_for_page_to_load() assert term in detail.name
def test_throttled_request_update_rating_spam(selenium, base_url, variables): # this test checks that repeatedly modifying the rating score will raise throttled request error extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('regular_user') # click ten times on rating star for i in range(10): addon.ratings.rating_stars[3].click() addon.wait.until( EC.visibility_of_element_located((By.CSS_SELECTOR, '.Notice-error'))) assert addon.ratings.throttled_request_error.is_displayed()
def test_select_result_with_click(base_url, selenium, variables): page = Home(selenium, base_url).open() term = variables['search_term'] suggestions = page.search.search_for(term, execute=False) result = suggestions[0].root action = ActionChains(selenium) action.move_to_element(result).click().perform() # give time to the detail page to load page.wait_for_title_update(term) detail = Detail(selenium, base_url) detail.wait_for_page_to_load() assert term in detail.name
def test_extension_permissions(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url) assert 'Permissions' in addon.permissions.permissions_card_header permissions = addon.permissions.permissions_list # checks that each permission has a corresponding icon and description for permission in permissions: assert permission.permission_icon.is_displayed() assert permission.permission_description.is_displayed() addon.permissions.click_permissions_button() addon.wait_for_current_url('permission-request')
def test_non_promoted_addon(selenium, base_url, variables): extension = variables['experimental_addon'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url) # check that the Promoted badge is not displayed with pytest.raises(NoSuchElementException): selenium.find_element_by_class_name('PromotedBadge-large') # checks the presence of an install warning assert addon.install_warning.is_displayed() assert variables[ 'install_warning_message'] in addon.install_warning_message addon.click_install_warning_button() assert 'add-on-badges' in selenium.current_url
def test_delete_review(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') addon.ratings.delete_review.click() assert 'review' in addon.ratings.ratings_card_summary assert 'review' in addon.ratings.delete_confirm_button.text assert 'review' in addon.ratings.keep_review_button.text addon.ratings.click_delete_confirm_button() # checks that the review text is no longer displayed with pytest.raises(NoSuchElementException): selenium.find_element_by_css_selector('.UserReview-body')
def test_developer_reply_to_review(selenium, base_url, variables): extension = variables['dev_reply_review'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('developer') reviews = addon.ratings.click_all_reviews_link() reviews.review_items[0].click_reply_to_review() reply_text = variables['initial_text_input'] reviews.review_items[0].reply_text_input(reply_text) reviews.review_items[0].publish_reply() assert 'Developer response' in reviews.review_items[ 0].dev_reply_header.text assert reply_text == reviews.review_items[0].posted_reply_text
def test_current_theme_not_in_more_by_artist_previews(selenium, base_url, variables): extension = variables['theme_detail_page'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() # makes a record of the preview image source displayed first in the more themes by artist # card, clicks on the preview and verifies that the theme is no longer present in # the preview list since it is the currently opened theme detail page theme_preview = addon.themes.more_themes_by_author_previews[ 0].get_attribute('src') addon.themes.more_themes_by_author_previews[0].click() addon.wait_for_page_to_load() assert theme_preview not in addon.themes.preview_source
def test_delete_developer_reply_to_review(selenium, base_url, variables): extension = variables['dev_reply_review'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('developer') reviews = addon.ratings.click_all_reviews_link() addon.ratings.delete_review.click() reviews.review_items[0].click_confirm_delete_button() # verifies that the Developer reply section is no longer displayed WebDriverWait(selenium, 10).until( EC.invisibility_of_element_located( (By.CSS_SELECTOR, '.AddonReviewCard-reply .ShowMoreCard-contents > div')))
def test_delete_rating(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') addon.ratings.delete_rating_link.click() assert 'rating' in addon.ratings.ratings_card_summary assert 'rating' in addon.ratings.delete_confirm_button.text assert 'rating' in addon.ratings.keep_review_button.text addon.ratings.click_delete_confirm_button() # verifies that rating stars are no longer full after deleting the rating WebDriverWait(selenium, 10).until( EC.invisibility_of_element_located( addon.ratings.selected_star_highlight))
def test_edit_review_in_all_reviews_page(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() addon.login('rating_user') reviews = addon.ratings.click_all_reviews_link() addon.ratings.edit_review.click() # edit the previous rating in All reviews page and verify that the score is updated reviews.edit_review_score[3].click() assert len(reviews.selected_score_highlight) == 4 # update the written review text in All reviews page edited_review_text = variables['edited_text_input'] addon.ratings.review_text_input(edited_review_text) addon.ratings.submit_review() assert edited_review_text in reviews.review_items[0].review_body
def test_lower_firefox_incompatibility(selenium, base_url, variables): extension = variables['lower_firefox_version'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url) assert ('This add-on is not compatible with your version of Firefox.' in addon.incompatibility_message) assert addon.button_state_disabled
def test_addon_recommendations(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() recommendations = addon.recommendations.addons_recommendations_results_list # verifies that the recommendations card shows up to 4 recommendations if available assert len(recommendations) <= 4
def test_release_notes(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() assert (f'Release notes for {addon.more_info.addon_version_number.text}' in addon.release_notes.release_notes_header) assert addon.release_notes.release_notes_text.is_displayed()
def test_add_to_collection_card(selenium, base_url, variables): extension = variables['detail_extension_slug'] selenium.get(f'{base_url}/addon/{extension}') addon = Detail(selenium, base_url).wait_for_page_to_load() # verifies that the Add to Collection card is present on the detail page assert 'Add to collection' in addon.add_to_collection.collections_card_header assert addon.add_to_collection.collections_select_field.is_displayed()