def test_contributor_flow_to_support_forum_post(self, base_url, selenium, 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 = QuestionsPage(base_url, selenium).open() questions_page.sign_in(user['username'], user['password']) questions_page.click_all_products() # 3.2 ensure the size of the list is 20 assert 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 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_that_questions_problem_count_increments(self, base_url, selenium): """Checks if the 'I have this problem too' counter increments""" # Can't +1 your own question so will do it logged out questions_page = QuestionsPage(base_url, selenium).open() questions_page.click_all_products() 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 initial_count + 1 == post_click_count
def test_that_questions_problem_count_increments(self, mozwebqa): """Checks if the 'I have this problem too' counter increments""" questions_pg = QuestionsPage(mozwebqa) view_question_pg = ViewQuestionPage(mozwebqa) # Can't +1 your own question so will do it logged out questions_pg.go_to_forum_questions_page() questions_pg.click_any_question(1) initial_count = view_question_pg.problem_count view_question_pg.click_problem_too_button() view_question_pg.refresh() post_click_count = view_question_pg.problem_count Assert.equal(initial_count + 1, post_click_count)
def test_questions_sorts_correctly_by_filter_equal_to_unanswered( self, base_url, selenium): """ Goes to the /questions page, Verifies the sort filter=unanswered works """ expected_sorted_text = "Unanswered" questions_page = QuestionsPage(base_url, selenium).open() 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 0 == question.number_of_replies
def test_that_questions_sorts_correctly_by_filter_equal_to_solved( self, base_url, selenium): """ Goes to the /questions page, Verifies the sort filter=solved works """ expected_sorted_text = "SOLVED" questions_page = QuestionsPage(base_url, selenium).open() 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 'highlighted' in question.solved_questions_filter
def test_that_questions_sorts_correctly_by_filter_equal_to_unanswered(self, base_url, selenium): """ Goes to the /questions page, Verifies the sort filter=unanswered works """ expected_sorted_text = "Unanswered" questions_page = QuestionsPage(base_url, selenium).open() 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 0 == question.number_of_replies
def test_that_questions_sorts_correctly_by_filter_equal_to_solved(self, mozwebqa): """ Goes to the /questions page, Verifies the sort filter=solved works """ questions_pg = QuestionsPage(mozwebqa) expected_sorted_text = "Solved" questions_pg.go_to_forum_questions_page() questions_pg.click_sort_by_solved_questions() # if there are no questions in the list then skip the test if not questions_pg.are_questions_present(): pytest.skip("No questions present for filter=%s" % expected_sorted_text) num_of_questions = questions_pg.get_questions_count for counter in range(num_of_questions): actual_sorted_text = questions_pg.get_sorted_list_filter_text(counter + 1) Assert.equal(actual_sorted_text, expected_sorted_text)
def test_that_questions_sorts_correctly_by_filter_equal_to_solved(self, base_url, selenium): """ Goes to the /questions page, Verifies the sort filter=solved works """ expected_sorted_text = "SOLVED" questions_page = QuestionsPage(base_url, selenium).open() 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 'highlighted' in question.solved_questions_filter
def test_contributor_flow_to_support_forum_post(self, base_url, selenium, 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 = QuestionsPage(base_url, selenium).open() questions_page.sign_in(user['username'], user['password']) questions_page.click_all_products() # 3.2 ensure the size of the list is 20 assert 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 forum_page.is_reply_text_present(user['username'], reply), \ u'reply with "%s" text posted by %s is not present' % ( reply, user['username'])
def questions_page(self, do_login=False, user='******'): from pages.desktop.questions_page import QuestionsPage return self._go_to_page(QuestionsPage(self.testsetup), do_login, user)
def questions_page(self, username=None, password=None): from pages.desktop.questions_page import QuestionsPage return self._go_to_page(QuestionsPage(self.testsetup), username, password)