def test_that_article_can_be_deleted(self, mozwebqa): """ Creates a new knowledge base article. Deletes the article. Verifies the deletion. """ kb_new_article = PageProvider(mozwebqa).new_kb_article_page() # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) # go to article and get URL kb_article = kb_article_history.navigation.click_article() article_url = kb_article.url_current_page # delete the same article kb_article_history = kb_article.navigation.click_show_history() kb_article_history.delete_entire_article_document() kb_article_history.selenium.get(article_url) actual_page_title = kb_article_history.page_title Assert.contains("Page Not Found", actual_page_title)
def test_login(self, mozwebqa, variables): user = variables['users']['default'] home_page = PageProvider(mozwebqa).home_page() home_page.sign_in(user['username'], user['password']) Assert.true(home_page.header.is_user_logged_in, 'User not shown to be logged in')
def test_that_article_can_be_created(self, mozwebqa): """ Creates a new knowledge base article. Verifies creation. Deletes the article """ kb_new_article = PageProvider(mozwebqa).new_kb_article_page() # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) # verify article contents kb_edit_article = kb_article_history.navigation.click_edit_article() actual_summary_text = kb_edit_article.article_summary_text Assert.equal(mock_article['summary'], actual_summary_text) actual_contents_text = kb_edit_article.article_contents_text Assert.equal(mock_article['content'], actual_contents_text) # delete the same article kb_article_history = kb_edit_article.navigation.click_show_history() kb_article_history.delete_entire_article_document()
def test_user_flow_to_forum_post(self, mozwebqa): if mozwebqa.base_url == 'https://support-dev.allizom.org': pytest.skip( 'Search results are not guaranteed to exist on support-dev.allizom.org' ) # 1. start on the home page PageProvider(mozwebqa).home_page() # 2. type "Firefox crashed" # 3. hit Enter search_pg = SearchPage(mozwebqa) search_pg.do_search_on_search_query(self.forum_search_term + "ed") # 4. In the results list there are two types of results: # Forum and KB. Click on a forum result. # (Url is in the forum of /questions/[some number]) # 5. A complete forum thread should be displayed. Assert.true(search_pg.is_result_present, "result page is not present.") result_thread_title = search_pg.result_question_text() Assert.contains(self.forum_search_term, result_thread_title) is_reached_right_page = search_pg.click_question_link( self.forum_search_term) Assert.true(is_reached_right_page, "a form thread page is not displayed.")
def test_logout_from_pages(self, mozwebqa, page_method): page_under_test = getattr(PageProvider(mozwebqa), page_method)(do_login=True, user='******') Assert.true(page_under_test.header.is_user_logged_in, 'User not shown to be logged in') # sign out page_under_test.sign_out() page_under_test.is_the_current_page Assert.true(page_under_test.header.is_user_logged_out)
def test_logout_from_new_kb_article_page(self, mozwebqa): new_kb_page = PageProvider(mozwebqa).new_kb_article_page() Assert.true(new_kb_page.header.is_user_logged_in, 'User not shown to be logged in') # sign out login_page = new_kb_page.sign_out() login_page.is_the_current_page Assert.true(login_page.header.is_user_logged_out)
def test_that_thank_you_page_is_displayed_after_successful_registration( self, mozwebqa): """ Register a new user using random username. Verify registration by checking the page title """ register_pg = PageProvider(mozwebqa).new_user_registration_page() register_pg.register_new_user() actual_page_title = register_pg.page_title expected_page_title = register_pg._page_title_after_registration Assert.contains(expected_page_title, actual_page_title)
def test_logout_from_new_kb_article_page(self, mozwebqa, variables): user = variables['users']['default'] new_kb_page = PageProvider(mozwebqa).new_kb_article_page( user['username'], user['password']) Assert.true(new_kb_page.header.is_user_logged_in, 'User not shown to be logged in') # sign out register_page = new_kb_page.sign_out() register_page.is_the_current_page Assert.true(register_page.header.is_user_logged_out)
def test_logout_from_pages(self, mozwebqa, variables, page_method): user = variables['users']['default'] page_under_test = getattr(PageProvider(mozwebqa), page_method)(user['username'], user['password']) Assert.true(page_under_test.header.is_user_logged_in, 'User not shown to be logged in') # sign out page_under_test.sign_out() page_under_test.is_the_current_page Assert.true(page_under_test.header.is_user_logged_out)
def test_that_questions_problem_count_increments(self, mozwebqa): """Checks if the 'I have this problem too' counter increments""" # Can't +1 your own question so will do it logged out questions_page = PageProvider(mozwebqa).questions_page() view_question_page = questions_page.click_any_question(1) initial_count = view_question_page.problem_count view_question_page.click_problem_too_button() view_question_page.refresh() post_click_count = view_question_page.problem_count Assert.equal(initial_count + 1, post_click_count)
def test_logout_from_edit_kb_article_page(self, mozwebqa): kb_new_article = PageProvider(mozwebqa).new_kb_article_page() # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box(mock_article['comment']) kb_edit_article = kb_article_history.navigation.click_edit_article() # sign out login_page = kb_edit_article.sign_out() login_page.is_the_current_page Assert.true(login_page.header.is_user_logged_out)
def test_that_article_can_be_previewed_before_submitting(self, mozwebqa): """ Start a new knowledge base article. Preview. Verify the contents in the preview """ kb_new_article = PageProvider(mozwebqa).new_kb_article_page() # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.click_article_preview_button() actual_preview_text = kb_new_article.article_preview_text Assert.equal(mock_article['content'], actual_preview_text)
def test_no_query_adv_forum_search(self, mozwebqa, variables): if mozwebqa.base_url in [ 'https://support-dev.allizom.org', 'https://support.mozilla.org' ]: pytest.skip('Search results are not guaranteed to exist on %s' % mozwebqa.base_url) refine_search_pg = PageProvider(mozwebqa).refine_search_page() # do test refine_search_pg.click_support_questions_tab() username = variables['users']['default']['username'] refine_search_pg.type_in_asked_by_box(username) refine_search_pg.click_search_button_support() Assert.true(refine_search_pg.search_result_count > 0, "No search results not found")
def test_logout_from_edit_kb_article_page(self, mozwebqa, variables): user = variables['users']['default'] kb_new_article = PageProvider(mozwebqa).new_kb_article_page( user['username'], user['password']) # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) kb_edit_article = kb_article_history.navigation.click_edit_article() # sign out register_page = kb_edit_article.sign_out() register_page.is_the_current_page Assert.true(register_page.header.is_user_logged_out)
def test_that_article_can_be_previewed_before_submitting( self, mozwebqa, variables): """ Start a new knowledge base article. Preview. Verify the contents in the preview """ user = variables['users']['default'] kb_new_article = PageProvider(mozwebqa).new_kb_article_page( user['username'], user['password']) # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.click_article_preview_button() actual_preview_text = kb_new_article.article_preview_text Assert.equal(mock_article['content'], actual_preview_text)
def test_logout_from_translate_kb_article_page(self, mozwebqa): kb_new_article = PageProvider(mozwebqa).new_kb_article_page() # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) kb_translate_pg = kb_article_history.navigation.click_translate_article( ) kb_translate_pg.click_translate_language('Deutsch (de)') # sign out register_page = kb_translate_pg.sign_out() register_page._page_title = 'Anmelden / Registrieren | Mozilla-Hilfe' register_page.is_the_current_page Assert.true(register_page.header.is_user_logged_out)
def test_that_questions_sorts_correctly_by_filter_equal_to_unanswered( self, mozwebqa): """ Goes to the /questions page, Verifies the sort filter=unanswered works """ expected_sorted_text = "Unanswered" questions_page = PageProvider(mozwebqa).questions_page() questions_page.click_all_products() questions_page.click_all_questions_tab() questions_page.click_sort_by_unanswered_questions() # if there are no questions in the list then skip the test if not questions_page.are_questions_present: pytest.skip("No questions present for filter=%s" % expected_sorted_text) for question in questions_page.questions: Assert.equal(0, question.number_of_replies)
def test_view_helpfulness_chart(self, mozwebqa): """ Creates a new knowledge base article. Verifies creation. Deletes the article. """ sumo_homepage = PageProvider(mozwebqa).home_page(do_login=True) sumo_homepage.header.dismiss_staging_site_warning_if_present() contrib_page = sumo_homepage.click_knowledge_base_dashboard_link() contrib_page.is_the_current_page contrib_page.click_all_time() kb_article = contrib_page.click_top_visited_article_link() # vote on article to artificially inflate data kb_article.vote() kb_article_history = kb_article.navigation.click_show_history() kb_article_history.click_show_helpfulness_chart() Assert.true(kb_article_history.is_helpfulness_chart_visible)
def test_that_posting_question_works(self, mozwebqa): """Posts a question to /questions""" timestamp = datetime.datetime.today() q_to_ask = "automation test question %s" % (timestamp) q_details = "This is a test. %s" % (timestamp) # go to the /questions/new page and log in ask_new_questions_page = PageProvider(mozwebqa).new_question_page() # post a question ask_new_questions_page.click_firefox_product_link() ask_new_questions_page.click_category_problem_link() ask_new_questions_page.type_question(q_to_ask) ask_new_questions_page.close_stage_site_banner() ask_new_questions_page.click_none_of_these_solve_my_problem_button() view_question_pg = ask_new_questions_page.fill_up_questions_form( q_to_ask, q_details) Assert.equal(view_question_pg.question, q_to_ask) Assert.equal(view_question_pg.question_detail, q_details)
def test_that_questions_sorts_correctly_by_filter_equal_to_no_replies( self, mozwebqa): """ Goes to the /questions page, Verifies the sort filter=noreplies works """ expected_sorted_text = "No replies" questions_page = PageProvider(mozwebqa).questions_page() questions_page.click_to_expand_sort_and_filter_box() Assert.true(questions_page.is_sort_and_filter_box_expanded) questions_page.click_sort_by_no_replies_questions() # if there are no questions in the list then skip the test if not questions_page.are_questions_present: pytest.skip("No questions present for filter=%s" % expected_sorted_text) for question in questions_page.questions: Assert.equal(0, question.number_of_replies)
def test_that_article_can_be_translated(self, mozwebqa, variables): """ Creates a new knowledge base article. Translate article """ user = variables['users']['admin'] kb_new_article = PageProvider(mozwebqa).new_kb_article_page( user['username'], user['password']) # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) # translating kb_translate_pg = kb_article_history.navigation.click_translate_article( ) kb_translate_pg.click_translate_language('Deutsch (de)') # enter the translation mock_article_deutsch = MockArticle(suffix="_deutsch") kb_translate_pg.type_title(mock_article_deutsch['title']) kb_translate_pg.type_slug(mock_article_deutsch['slug']) kb_translate_pg.type_search_result_summary( mock_article_deutsch['summary']) kb_translate_pg.click_submit_review() change_comment = mock_article_deutsch['comment'] kb_translate_pg.type_modal_describe_changes(change_comment) kb_article_history = kb_translate_pg.click_modal_submit_changes_button( ) # verifying Assert.equal(change_comment, kb_article_history.most_recent_revision_comment) Assert.contains('Deutsch', kb_article_history.revision_history) # deleting kb_article_history.delete_entire_article_document()
def test_that_questions_sorts_correctly_by_filter_equal_to_solved( self, mozwebqa): """ Goes to the /questions page, Verifies the sort filter=solved works """ expected_sorted_text = "SOLVED" questions_page = PageProvider(mozwebqa).questions_page() questions_page.click_all_products() questions_page.click_questions_done_tab() questions_page.click_sort_by_solved_questions() # if there are no questions in the list then skip the test if not questions_page.are_questions_present: pytest.skip("No questions present for filter=%s" % expected_sorted_text) for question in questions_page.questions: # if solved mark is highlighted the question is really solved Assert.true('highlighted' in question.solved_questions_filter)
def test_that_questions_sorts_correctly_by_filter_equal_to_solved( self, mozwebqa): """ Goes to the /questions page, Verifies the sort filter=solved works """ expected_sorted_text = "SOLVED" questions_page = PageProvider(mozwebqa).questions_page() questions_page.click_to_expand_sort_and_filter_box() Assert.true(questions_page.is_sort_and_filter_box_expanded) questions_page.click_sort_by_solved_questions() # if there are no questions in the list then skip the test if not questions_page.are_questions_present: pytest.skip("No questions present for filter=%s" % expected_sorted_text) for question in questions_page.questions: actual_sorted_text = question.sorted_list_filter_text Assert.equal(actual_sorted_text, expected_sorted_text)
def test_that_article_can_be_edited(self, mozwebqa, variables): """ Creates a new knowledge base article. Verifies creation. Edits the article, verifies the edition. Deletes the article """ user = variables['users']['admin'] kb_new_article = PageProvider(mozwebqa).new_kb_article_page( user['username'], user['password']) # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) # edit that same article (keep the title the same as original) mock_article_edited = MockArticle(suffix="_edited", title=mock_article['title']) kb_edit_article = kb_article_history.navigation.click_edit_article() kb_article_history = kb_edit_article.edit_article(mock_article_edited) kb_edit_article = kb_article_history.navigation.click_edit_article() # verify the contents of the edited article actual_page_title = kb_edit_article.page_title Assert.contains(mock_article_edited['title'], actual_page_title) actual_summary_text = kb_edit_article.article_summary_text Assert.equal(mock_article_edited['summary'], actual_summary_text) actual_content_text = kb_edit_article.article_contents_text Assert.equal(mock_article_edited['content'], actual_content_text) # delete the same article kb_article_history = kb_edit_article.navigation.click_show_history() kb_article_history.delete_entire_article_document()
def test_that_article_can_be_translated(self, mozwebqa): """ Creates a new knowledge base article. Translate article """ kb_new_article = PageProvider(mozwebqa).new_kb_article_page() # create a new article mock_article = MockArticle() kb_new_article.set_article(mock_article) kb_new_article.submit_article() kb_article_history = kb_new_article.set_article_comment_box( mock_article['comment']) # translating kb_translate_pg = kb_article_history.navigation.click_translate_article( ) kb_translate_pg.click_translate_language('Esperanto (eo)') #enter the tranlation mock_article_esperanto = MockArticle(suffix="_esperanto") kb_translate_pg.type_title(mock_article_esperanto['title']) kb_translate_pg.type_slug(mock_article_esperanto['slug']) kb_translate_pg.type_search_result_summary( mock_article_esperanto['summary']) kb_translate_pg.click_submit_review() change_comment = mock_article_esperanto['comment'] kb_translate_pg.type_modal_describe_changes(change_comment) kb_article_history = kb_translate_pg.click_modal_submit_changes_button( ) # verifying Assert.equal(change_comment, kb_article_history.most_recent_revision_comment) Assert.contains('Esperanto', kb_article_history.revision_history) # deleting kb_article_history.delete_entire_article_document()
def test_contributor_flow_to_support_forum_post(self, mozwebqa, variables): """ Shows a contributor can start on the home page and move all the way to answering a question in the forum. """ # 1. Start on the home page # 2. Log in # 3. Use the contributor bar to go to the forums. # The questions page should list 20 posts. # 3.1 go to the question page user = variables['users']['default'] questions_page = PageProvider(mozwebqa).questions_page( user['username'], user['password']) questions_page.click_all_products() # 3.2 ensure the size of the list is 20 Assert.greater(questions_page.questions_count, 0, 'There is not at least one question displayed.') # 4. Click on a question. (URL is in the forum of /questions/[some number]) # 4.1 pick up an arbitrary question and click # 4.2 check if it landed on an intended forum page question = questions_page.questions[randrange( questions_page.questions_count)] forum_page = question.click_question_link() # 5. Go to the thread # 6. Scroll to the bottom and click into the text field # 7. Type reply # 7.1 reply the post reply = "reply" forum_page.post_reply(reply) # 7.2 check if posting a reply finishes without an error Assert.true( forum_page.is_reply_text_present(user['username'], reply), u'reply with "%s" text posted by %s is not present' % (reply, user['username']))
def test_switch_to_mobile_view(self, mozwebqa): home = PageProvider(mozwebqa).home_page() home.switch_to_mobile_view() mobile = MobilePageProvider(mozwebqa).home_page() Assert.true(mobile.is_mobile_view_displayed)
def test_login(self, mozwebqa): home_page = PageProvider(mozwebqa).home_page() home_page.sign_in(user='******') Assert.true(home_page.header.is_user_logged_in, 'User not shown to be logged in')