diff --git a/playwright_tests/pages/user_pages/my_profile_my_questions_page.py b/playwright_tests/pages/user_pages/my_profile_my_questions_page.py index 4d991d5e7c5..9721dee1e76 100644 --- a/playwright_tests/pages/user_pages/my_profile_my_questions_page.py +++ b/playwright_tests/pages/user_pages/my_profile_my_questions_page.py @@ -27,6 +27,10 @@ def click_on_a_question_by_index(self, index_of_question: int): xpath = f"//article[@id='profile']/ul/a[{index_of_question}]/li" super()._click(xpath) + def click_on_a_question_by_name(self, question_title: str): + xpath = f"//article[@id='profile']/ul/a/li[text()='{question_title}']" + super()._click(xpath) + def get_text_of_first_listed_question(self) -> str: xpath = "//article[@id='profile']/ul/a[1]" return super()._get_element_inner_text_from_page(xpath) diff --git a/playwright_tests/tests/aaq_tests/test_aaq_page.py b/playwright_tests/tests/aaq_tests/test_aaq_page.py index a35b1c852dc..8660ea98e4d 100644 --- a/playwright_tests/tests/aaq_tests/test_aaq_page.py +++ b/playwright_tests/tests/aaq_tests/test_aaq_page.py @@ -244,7 +244,9 @@ def test_post_aaq_questions_for_all_freemium_products_topics(self): ).to_be_visible() self.logger.info("Clicking on the question and deleting it") - self.sumo_pages.my_questions_page.click_on_a_question_by_index(1) + self.sumo_pages.my_questions_page.click_on_a_question_by_name( + question_info['aaq_subject'] + ) self.sumo_pages.question_page.click_delete_this_question_question_tools_option() self.sumo_pages.question_page.click_delete_this_question_button() diff --git a/playwright_tests/tests/product_solutions_page_tests/test_product_solutions_page.py b/playwright_tests/tests/product_solutions_page_tests/test_product_solutions_page.py index 63e71990abe..e4011b6fcaa 100644 --- a/playwright_tests/tests/product_solutions_page_tests/test_product_solutions_page.py +++ b/playwright_tests/tests/product_solutions_page_tests/test_product_solutions_page.py @@ -1,7 +1,7 @@ import pytest import pytest_check as check -from playwright.sync_api import expect +from playwright.sync_api import expect, TimeoutError from playwright_tests.core.testutilities import TestUtilities from playwright_tests.messages.AAQ_messages.aaq_widget import AAQWidgetMessages from playwright_tests.messages.product_solutions_page_messages.product_solutions_messages import ( @@ -78,10 +78,17 @@ def test_popular_topics_redirect(self): if self.sumo_pages.product_solutions_page._is_popular_topics_section_displayed: for topic in self.sumo_pages.product_solutions_page._get_popular_topics(): self.sumo_pages.product_solutions_page._click_on_a_popular_topic_card(topic) - - with self.page.context.expect_page() as tab: - feature_article_page = tab.value - print("Tab open") + try: + with self.page.context.expect_page() as tab: + feature_article_page = tab.value + print(f"Tab open for topic: {topic}") + except TimeoutError: + print("Trying to click on the popular topic again") + self.sumo_pages.product_solutions_page._click_on_a_popular_topic_card( + topic) + with self.page.context.expect_page() as tab: + feature_article_page = tab.value + print(f"Tab open for topic: {topic}") popular_topic = (feature_article_page .locator("//h1[@class='topic-title sumo-page-heading']") @@ -94,7 +101,6 @@ def test_popular_topics_redirect(self): f"Received: {popular_topic}" ) feature_article_page.close() - else: self.logger.info(f"{card} has no featured articles displayed!!!")