Skip to content

Commit

Permalink
Merge pull request #6353 from emilghittasv/playwright--further-testfixes
Browse files Browse the repository at this point in the history
Playwright try fixing recent AAQ and top-navbar related test failures/flakiness
  • Loading branch information
emilghittasv authored Nov 13, 2024
2 parents befa48d + 8dd4ae5 commit 9318396
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
if: success() || failure() && steps.create-sessions.outcome == 'success'
run: |
declare dispatch_test_suite="${{inputs.TestSuite}}"
declare all_test_suites=("homePageTests" "topNavbarTests" "footerSectionTests" "contributePagesTests" "messagingSystem" "messagingSystemCleanup" "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions" "contactSupportPage" "productSolutionsPage" "productSupportPage" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "kbRestrictedVisibility" "kbArticleTranslation" "exploreByTopics", "searchTests", "userGroupsTests")
declare all_test_suites=("homePageTests" "topNavbarTests" "footerSectionTests" "contributePagesTests" "messagingSystem" "messagingSystemCleanup" "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions" "contactSupportPage" "productSolutionsPage" "productSupportPage" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "kbRestrictedVisibility" "kbArticleTranslation" "exploreByTopics" "searchTests" "userGroupsTests")
if [ "$dispatch_test_suite" == "All" ] || [ "${{ github.event_name}}" == "schedule" ] ; then
for test in "${all_test_suites[@]}"; do
if ! poetry run pytest -m ${test} --numprocesses 4 --browser ${{ env.BROWSER }} --reruns 1; then
Expand Down
48 changes: 22 additions & 26 deletions playwright_tests/pages/top_navbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,24 @@ def hover_over_explore_by_product_top_navbar_option(self):
"""Hover over the 'Explore by product' top-navbar option"""
self._hover_over_element(self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS
["explore_help_articles_top_navbar_option"])
self.page.wait_for_selector(
self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS["explore_by_product_top_navbar_header"])

def get_all_explore_by_product_options_locators(self) -> list[Locator]:
"""Get all 'Explore by product' top-navbar options locators"""
self.hover_over_explore_by_product_top_navbar_option()
self.page.wait_for_selector(
self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS["explore_by_product_top_navbar_header"])
return self._get_elements_locators(self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS
["explore_by_product_top_navbar_options"])

def get_all_explore_by_topic_locators(self) -> list[Locator]:
"""Get all 'Explore by topic' top-navbar options locators"""
self.hover_over_explore_by_product_top_navbar_option()
self.page.wait_for_selector(self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS
["explore_by_topic_top_navbar_header"])
return self._get_elements_locators(self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS
["explore_by_topic_top_navbar_options"])

def click_on_explore_our_help_articles_view_all_option(self):
"""Click on the 'View all products' option"""
self._hover_over_element(self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS
["explore_help_articles_top_navbar_option"])
self.hover_over_explore_by_product_top_navbar_option()
self._click(self.TOP_NAVBAR_EXPLORE_HELP_ARTICLES_LOCATORS
["explore_our_help_articles_view_all_option"])
"""
Expand All @@ -148,20 +145,18 @@ def hover_over_community_forums_top_navbar_option(self):
"""Hover over the 'Community Forums' top-navbar option"""
self._hover_over_element(self.TOP_NAVBAR_COMMUNITY_FORUMS_LOCATORS
["community_forums_top_navbar_option"])
self.page.wait_for_selector(self.TOP_NAVBAR_COMMUNITY_FORUMS_LOCATORS
["browse_by_product_top_navbar_header"])

def get_all_browse_by_product_options_locators(self) -> list[Locator]:
"""Get all 'Browse by product' top-navbar options locators"""
self.hover_over_community_forums_top_navbar_option()
self.page.wait_for_selector(self.TOP_NAVBAR_COMMUNITY_FORUMS_LOCATORS
["browse_by_product_top_navbar_header"])
return self._get_elements_locators(self.TOP_NAVBAR_COMMUNITY_FORUMS_LOCATORS
["browse_by_product_top_navbar_options"])

def get_all_browse_all_forum_threads_by_topic_locators(self) -> list[Locator]:
"""Get all 'Browse all forum threads by topic' top-navbar options locators"""
self.hover_over_community_forums_top_navbar_option()
self.page.wait_for_selector(self.TOP_NAVBAR_COMMUNITY_FORUMS_LOCATORS
["browse_all_forum_threads_by_topic_top_navbar_header"])
return self._get_elements_locators(
self.TOP_NAVBAR_COMMUNITY_FORUMS_LOCATORS
["browse_all_forum_threads_by_topics_top_navbar_options"])
Expand All @@ -172,17 +167,17 @@ def get_all_browse_all_forum_threads_by_topic_locators(self) -> list[Locator]:
def hover_over_ask_a_question_top_navbar(self):
"""Hover over the 'Ask a Question' top-navbar option"""
self._hover_over_element(self.TOP_NAVBAR_AAQ_LOCATORS["ask_a_question_top_navbar"])
self.page.wait_for_selector(self.TOP_NAVBAR_AAQ_LOCATORS["get_help_with_heading"])

def get_all_ask_a_question_locators(self) -> list[Locator]:
"""Get all 'Ask a Question' top-navbar options locators"""
self._hover_over_element(self.TOP_NAVBAR_AAQ_LOCATORS["ask_a_question_top_navbar"])
self.page.wait_for_selector(self.TOP_NAVBAR_AAQ_LOCATORS["get_help_with_heading"])
self.hover_over_ask_a_question_top_navbar()
return self._get_elements_locators(self.TOP_NAVBAR_AAQ_LOCATORS
["ask_a_question_top_navbar_options"])

def click_on_browse_all_products_option(self):
"""Click on the 'Browse all products' option"""
self._hover_over_element(self.TOP_NAVBAR_AAQ_LOCATORS["ask_a_question_top_navbar"])
self.hover_over_ask_a_question_top_navbar()
self._click(self.TOP_NAVBAR_AAQ_LOCATORS["browse_all_products_option"])

"""
Expand All @@ -191,12 +186,12 @@ def click_on_browse_all_products_option(self):
def hover_over_contribute_top_navbar(self):
"""Hover over the 'Contribute' top-navbar option"""
self._hover_over_element(self.TOP_NAVBAR_CONTRIBUTE_LOCATORS["contribute_option"])
self.page.wait_for_selector(self.TOP_NAVBAR_CONTRIBUTE_LOCATORS
["contributor_discussions_top_navbar_header"])

def get_all_contributor_discussions_locators(self) -> list[Locator]:
"""Get all 'Contributor discussions' top-navbar options locators"""
self.hover_over_contribute_top_navbar()
self.page.wait_for_selector(self.TOP_NAVBAR_CONTRIBUTE_LOCATORS
["contributor_discussions_top_navbar_header"])
return self._get_elements_locators(self.TOP_NAVBAR_CONTRIBUTE_LOCATORS
["contributor_discussions_options"])

Expand All @@ -211,7 +206,7 @@ def click_on_community_discussions_top_navbar_option(self):

def click_on_article_discussions_option(self):
"""Click on the 'Article discussions' option"""
self._hover_over_element(self.TOP_NAVBAR_CONTRIBUTE_LOCATORS["contribute_option"])
self.hover_over_contribute_top_navbar()
self._click(self.TOP_NAVBAR_CONTRIBUTE_LOCATORS["article_discussions_option"])

# Contributor tools
Expand Down Expand Up @@ -247,9 +242,14 @@ def click_on_signin_signup_button(self):
"""Click on the 'Sign In/Up' button"""
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signin_signup_button"])

def mouse_over_profile_avatar(self):
"""Mouse over the profile avatar"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self._wait_for_selector(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["sign_out_button"])

def click_on_sign_out_button(self):
"""Click on the 'Sign Out' button"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self.mouse_over_profile_avatar()
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["sign_out_button"])

def sign_in_up_button_displayed_element(self) -> Locator:
Expand All @@ -267,39 +267,39 @@ def is_sign_in_up_button_displayed(self) -> bool:
"""
def click_on_view_profile_option(self):
"""Click on the 'View Profile' option"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self.mouse_over_profile_avatar()
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_view_profile_option"])
# Sometimes the top-navbar is not hidden after clicking on the 'Settings' option. This
# action is to move the mouse to the top-left corner of the page to hide the top-navbar.
self._move_mouse_to_location(0, 0)

def click_on_edit_profile_option(self):
"""Click on the 'Edit Profile' option"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self.mouse_over_profile_avatar()
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_edit_profile_option"])
# Sometimes the top-navbar is not hidden after clicking on the 'Settings' option. This
# action is to move the mouse to the top-left corner of the page to hide the top-navbar.
self._move_mouse_to_location(0, 0)

def click_on_settings_profile_option(self):
"""Click on the 'Settings' option"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self.mouse_over_profile_avatar()
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_settings_option"])
# Sometimes the top-navbar is not hidden after clicking on the 'Settings' option. This
# action is to move the mouse to the top-left corner of the page to hide the top-navbar.
self._move_mouse_to_location(0, 0)

def click_on_inbox_option(self):
"""Click on the 'Inbox' option"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self.mouse_over_profile_avatar()
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_inbox_option"])
# Sometimes the top-navbar is not hidden after clicking on the 'Settings' option. This
# action is to move the mouse to the top-left corner of the page to hide the top-navbar.
self._move_mouse_to_location(0, 0)

def click_on_my_questions_profile_option(self):
"""Click on the 'My Questions' option"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])
self.mouse_over_profile_avatar()
self._click(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_my_questions_option"])
# Sometimes the top-navbar is not hidden after clicking on the 'Settings' option. This
# action is to move the mouse to the top-left corner of the page to hide the top-navbar.
Expand All @@ -325,10 +325,6 @@ def is_unread_message_notification_counter_visible(self) -> bool:
return self._is_element_visible(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS
["unread_message_count"])

def mouse_over_profile_avatar(self):
"""Mouse over the profile avatar"""
self._hover_over_element(self.TOP_NAVBAR_SIGNIN_SIGNUP_LOCATORS["signed_in_username"])

"""
General actions against the top-navbar section.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def test_post_aaq_questions_for_all_freemium_products_topics(page: Page):
topic_name=topic,
body=utilities.aaq_question_test_data["valid_firefox_question"]
["question_body"],
attach_image=False
attach_image=False,
expected_locator=sumo_pages.question_page.QUESTION_LOCATORS
["questions_header"]
)

with allure.step("Verifying that the correct implicit tags are added to the "
Expand Down Expand Up @@ -387,7 +389,8 @@ def test_additional_system_details_user_agent_information(page: Page):
topic_name=sumo_pages.aaq_form_page.get_aaq_form_topic_options()[0],
body=utilities.aaq_question_test_data["valid_firefox_question"]
["question_body"],
attach_image=True
attach_image=True,
expected_locator=sumo_pages.question_page.QUESTION_LOCATORS["questions_header"]
)

with check, allure.step("Verifying that the correct user-agent information is "
Expand Down

0 comments on commit 9318396

Please sign in to comment.