From 1cd545467a0a04243c753bf42b7411371c3f3c1c Mon Sep 17 00:00:00 2001 From: Emil Ghitta Date: Fri, 15 Dec 2023 12:45:38 +0200 Subject: [PATCH] - Fix failing AAQ and product solutions tests in Chrome. --- .../user_pages/my_profile_my_questions_page.py | 4 ++++ .../tests/aaq_tests/test_aaq_page.py | 4 +++- .../test_product_solutions_page.py | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) 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 4d991d5e7..9721dee1e 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 @@ class MyProfileMyQuestionsPage(BasePage): 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 a35b1c852..8660ea98e 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 @@ class TestAAQPage(TestUtilities): ).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 63e71990a..e4011b6fc 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 @@ class TestProductSolutionsPage(TestUtilities): 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 @@ class TestProductSolutionsPage(TestUtilities): f"Received: {popular_topic}" ) feature_article_page.close() - else: self.logger.info(f"{card} has no featured articles displayed!!!")