Skip to content

Commit c2b74f0

Browse files
authored
Merge pull request #7387 from emilghittasv/playwright-fix-aaq-test
Playwright: Update locators & tests targeting the My Questions & Community forums page
2 parents eb5b1e6 + 2092c8d commit c2b74f0

6 files changed

Lines changed: 24 additions & 42 deletions

File tree

playwright_tests/pages/ask_a_question/posted_question_pages/questions_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, page: Page):
3939
self.reply_solution_header = lambda reply_id: page.locator(
4040
f"div#{reply_id} h3[class='is-solution']")
4141

42-
"""Genera question locators."""
42+
"""General question locators."""
4343
self.question_author = page.locator("div[class='question'] span[class='display-name']")
4444
self.questions_header = page.locator(
4545
"h2[class='sumo-callout-heading summary no-product-heading']")

playwright_tests/pages/community_forums/forums_pages/product_support_forum.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ def __init__(self, page: Page):
2222
"//div[@id='questions-list']//h2[@class='forum--question-item-heading']/a")
2323
self.question_tag_list = lambda question_id: page.locator(
2424
f"article#{question_id} li.tag")
25-
self.is_spam_locator = page.locator("//div[@id='questions-list']//li[@class='is-spam']")
25+
self.is_spam_locator = page.locator("//div[@id='questions-list']//span[text()='Spam']")
2626
self.is_spam_locator_for_question = lambda question_id: page.locator(
27-
f"//div[@id='questions-list']//article[@id='{question_id}']//li[@class='is-spam']")
27+
f"//div[@id='questions-list']//article[@id='{question_id}']//span[text()='Spam']")
2828
self.question_solved_indicator = lambda question_id: page.locator(
29-
f"//article[@id='{question_id}']//li[@class='thread-solved']")
30-
self.question_contributed_indicator = lambda question_id: page.locator(
31-
f"//article[@id='{question_id}']//li[@class='thread-contributed']")
29+
f"//article[@id='{question_id}']//span[text()='Solved']")
3230
self.question_archived_indicator = lambda question_id: page.locator(
33-
f"//article[@id='{question_id}']//li[@class='thread-archived']")
31+
f"//article[@id='{question_id}']//span[text()='Archived']")
3432
self.question_locked_indicator = lambda question_id: page.locator(
35-
f"//article[@id='{question_id}']//li[@class='thread-locked']")
33+
f"//article[@id='{question_id}']//span[text()='Locked']")
3634

3735
"""Locators belonging to the filter options sections."""
3836
self.selected_tab_filter = page.locator(
@@ -151,14 +149,6 @@ def is_question_solved_indicator_displayed(self, question_id: str) -> bool:
151149
"""
152150
return self._is_element_visible(self.question_solved_indicator(question_id))
153151

154-
def is_question_contributed_indicator_displayed(self, question_id: str) -> bool:
155-
"""
156-
Return if the contributed indicator is displayed for a certain question or not.
157-
Args:
158-
question_id (str): The question ID.
159-
"""
160-
return self._is_element_visible(self.question_contributed_indicator(question_id))
161-
162152
def is_question_archived_indicator_displayed(self, question_id: str) -> bool:
163153
"""
164154
Return if the archived indicator is displayed for a certain question or not.

playwright_tests/pages/user_pages/my_profile_my_questions_page.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ def __init__(self, page: Page):
88

99
"""Locators belonging to the My Questions profile page."""
1010
self.questions_page_heading = page.locator("h2[class='sumo-page-subheading']")
11-
self.questions_no_question_message = page.locator("article#profile p")
12-
self.questions_list = page.locator("article#profile ul a")
13-
self.questions_titles = page.locator("article#profile ul a li")
14-
self.questions_by_index = lambda index: page.locator(
15-
f"//article[@id='profile']/ul/a[{index}]/li")
16-
self.question_by_name = lambda name: page.locator("article#profile ul a li").get_by_text(
17-
name, exact=True)
11+
self.questions_no_question_message = page.locator("//p[@class='my-questions--empty']")
12+
self.questions_list = page.locator("//a[@class='question-entry--title-link']")
13+
self.questions_titles = page.locator("//h3[@class='question-entry--title']")
14+
self.question_by_name = lambda name: page.locator(
15+
f"//a[@class='question-entry--title-link' and text()='{name}']")
1816

1917
"""Actions against the My Questions profile page locators."""
2018
def get_text_of_no_question_message(self) -> str:
@@ -27,15 +25,15 @@ def get_number_of_questions(self) -> int:
2725

2826
def click_on_a_question_by_index(self, index_of_question: int):
2927
"""Clicks on a question by its index."""
30-
self._click(self.questions_by_index(index_of_question))
28+
self._click(self.questions_titles.nth(index_of_question))
3129

3230
def click_on_a_question_by_name(self, question_title: str):
3331
"""Clicks on a question by its title."""
3432
self._click(self.question_by_name(question_title))
3533

3634
def get_text_of_listed_question_by_index(self, index: int) -> str:
3735
"""Returns the text of the first listed question."""
38-
return self._get_text_of_element(self.questions_by_index(index))
36+
return self._get_text_of_element(self.questions_titles.nth(index))
3937

4038

4139
def get_all_my_posted_questions(self) -> list[str]:

playwright_tests/tests/ask_a_question_tests/aaq_tests/test_posted_questions.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def test_mark_as_spam_functionality(page: Page, create_user_factory):
620620
@pytest.mark.smokeTest
621621
@pytest.mark.postedQuestions
622622
@pytest.mark.parametrize("user_type", ['', 'Simple User'])
623-
def test_question_topics(page: Page, user_type, create_user_factory):
623+
def test_question_tags(page: Page, user_type, create_user_factory):
624624
utilities = Utilities(page)
625625
sumo_pages = SumoPages(page)
626626
test_user = create_user_factory()
@@ -680,13 +680,12 @@ def test_question_topics(page: Page, user_type, create_user_factory):
680680
assert (question == sumo_pages.product_support_forum.
681681
get_text_of_selected_tag_filter_option())
682682

683-
with check, allure.step("Verifying that each listed question inside the product "
684-
"forum contains the filtered tab"):
685-
for article_id in sumo_pages.product_support_forum.extract_question_ids(
686-
):
687-
assert (question in sumo_pages.product_support_forum.
688-
get_all_question_list_tags(article_id))
689-
utilities.navigate_back()
683+
with allure.step("Verifying that the question is successfully displayed"):
684+
assert (
685+
posted_question["question_details"]["question_id"
686+
] in sumo_pages.product_support_forum.get_ids_of_all_listed_questions())
687+
utilities.navigate_to_link(
688+
posted_question['question_details']['question_page_url'])
690689

691690
with allure.step("Navigate back to the posted question, signing in with a Forum Moderator "
692691
"account and removing the newly added tag"):

playwright_tests/tests/ask_a_question_tests/community_forums/test_community_forums_by_product.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,6 @@ def test_questions_transitions_on_status_change(page: Page, create_user_factory,
401401
assert (question_details["question_id"] in sumo_pages.product_support_forum.
402402
get_ids_of_all_listed_questions())
403403

404-
assert sumo_pages.product_support_forum.is_question_contributed_indicator_displayed(
405-
question_details["question_id"])
406-
407404
if question_status == "has_solution":
408405
assert sumo_pages.product_support_forum.is_question_solved_indicator_displayed(
409406
question_details["question_id"])
@@ -438,8 +435,6 @@ def test_questions_transitions_on_status_change(page: Page, create_user_factory,
438435
sumo_pages.product_support_forum.click_on_a_certain_tab_filter("Responded")
439436
assert (question_details["question_id"] in sumo_pages.product_support_forum.
440437
get_ids_of_all_listed_questions())
441-
assert sumo_pages.product_support_forum.is_question_contributed_indicator_displayed(
442-
question_details["question_id"])
443438
assert not sumo_pages.product_support_forum.is_question_solved_indicator_displayed(
444439
question_details["question_id"])
445440
assert not sumo_pages.product_support_forum.is_question_archived_indicator_displayed(

playwright_tests/tests/user_page_tests/test_my_questions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,18 @@ def test_question_page_reflects_posted_questions_and_redirects_to_question(page:
133133
with check, allure.step("Navigating to my questions profile page and verifying that the first "
134134
"element from the My Questions page is the recently posted question"):
135135
sumo_pages.top_navbar.click_on_my_questions_profile_option()
136-
assert (sumo_pages.my_questions_page.get_text_of_listed_question_by_index(1).
136+
assert (sumo_pages.my_questions_page.get_text_of_listed_question_by_index(0).
137137
strip() == second_question["aaq_subject"].strip())
138-
assert (sumo_pages.my_questions_page.get_text_of_listed_question_by_index(2).
138+
assert (sumo_pages.my_questions_page.get_text_of_listed_question_by_index(1).
139139
strip() == first_question["aaq_subject"].strip())
140140

141141
with allure.step("Clicking on the first list item and verifying that the user is "
142142
"redirected to the correct question"):
143-
sumo_pages.my_questions_page.click_on_a_question_by_index(1)
143+
sumo_pages.my_questions_page.click_on_a_question_by_index(0)
144144
expect(page).to_have_url(second_question["question_page_url"])
145145

146146
with allure.step("Navigating back, clicking on the second listed item and verifying that the "
147147
"user is redirected to the correct question"):
148148
utilities.navigate_back()
149-
sumo_pages.my_questions_page.click_on_a_question_by_index(2)
149+
sumo_pages.my_questions_page.click_on_a_question_by_index(1)
150150
expect(page).to_have_url(first_question["question_page_url"])

0 commit comments

Comments
 (0)