Skip to content

Commit

Permalink
Merge pull request #6293 from emilghittasv/playwright-contributors-su…
Browse files Browse the repository at this point in the history
…pport-tests

Playwright enable productSupportPage tests, expand coverage over Contributors Support & some refactoring
  • Loading branch information
emilghittasv authored Oct 15, 2024
2 parents adcadfd + ff17a95 commit 98e8391
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 193 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ on:
- User Pages
- contactSupportPage
- productSolutionsPage
- productSupportPage
- productTopicsPage
- AAQ
- KB Articles
Expand Down Expand Up @@ -102,7 +103,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" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "kbRestrictedVisibility" "kbArticleTranslation" "exploreByTopics", "searchTests")
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")
if [ "$dispatch_test_suite" == "All" ] || [ "${{ github.event_name}}" == "schedule" ] ; then
for test in "${all_test_suites[@]}"; do
if ! poetry run pytest -m ${test} --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ def __init__(self, page: Page):
super().__init__(page)

# Page breadcrumbs actions.
def _click_on_first_breadcrumb(self):
super()._click(self.__first_breadcrumb)
def click_on_first_breadcrumb(self):
self._click(self.__first_breadcrumb)

# Page content actions.
def _get_page_header(self) -> str:
return super()._get_text_of_element(self.__page_header)
def get_page_header(self) -> str:
return self._get_text_of_element(self.__page_header)

# Product card actions.
def _get_subheading_of_card(self, card_title: str) -> str:
return super()._get_text_of_element(f"//a[normalize-space(text())='{card_title}']/../"
f"following-sibling::p[@class='card--desc']")
def get_subheading_of_card(self, card_title: str) -> str:
return self._get_text_of_element(f"//a[normalize-space(text())='{card_title}']/../"
f"following-sibling::p[@class='card--desc']")

def _click_on_a_particular_product_support_card(self, card_title):
super()._click(f"//div[@class='card--details']//a[normalize-space(text())='{card_title}']")
def click_on_a_particular_product_support_card(self, card_title):
self._click(f"//div[@class='card--details']//a[normalize-space(text())='{card_title}']")

def _get_all_product_support_titles(self) -> list[str]:
return super()._get_text_of_elements(self.__all_product_card_titles)
def get_all_product_support_titles(self) -> list[str]:
return self._get_text_of_elements(self.__all_product_card_titles)
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ class ProductSupportPage(BasePage):
__frequent_topics_section_title = "//h2[contains(text(),'Frequent Topics')]"
__frequent_topics_section_subtitle = ("//h2[contains(text(),'Frequent "
"Topics')]/following-sibling::p")
__frequent_topic_all_cards = ("//h2[contains(text(),'Frequent Topics')]/../../../..//a["
"@data-event-action='topic']")
__frequent_topic_all_cards = "//div[contains(@class,'card card--topic')]//a"

# Still need help widget locators.
__still_need_help_widget = ("//section[@class='support-callouts mzp-l-content sumo-page-"
"section--inner']")
__still_need_help_widget_title = ("//section[@class='support-callouts mzp-l-content "
"sumo-page-section--inner']//h3[@class='card--title']")
__still_need_help_widget_details = ("//section[@class='support-callouts mzp-l-content "
Expand All @@ -38,67 +39,71 @@ class ProductSupportPage(BasePage):
def __init__(self, page: Page):
super().__init__(page)

def _click_on_product_support_home_breadcrumb(self):
super()._click(self.__home_breadcrumb)
def click_on_product_support_home_breadcrumb(self):
self._click(self.__home_breadcrumb)

def _get_product_support_title_text(self) -> str:
return super()._get_text_of_element(self.__product_title)
def get_product_support_title_text(self) -> str:
return self._get_text_of_element(self.__product_title)

def _product_product_title_element(self) -> Locator:
return super()._get_element_locator(self.__product_title)
def product_product_title_element(self) -> Locator:
return self._get_element_locator(self.__product_title)

def _is_frequent_topics_section_displayed(self) -> bool:
return super()._is_element_visible(self.__frequent_topics_section_title)
def is_frequent_topics_section_displayed(self) -> bool:
return self._is_element_visible(self.__frequent_topics_section_title)

def _get_frequent_topics_title_text(self) -> str:
return super()._get_text_of_element(self.__frequent_topics_section_title)
def get_frequent_topics_title_text(self) -> str:
return self._get_text_of_element(self.__frequent_topics_section_title)

def _get_all_frequent_topics_cards(self) -> list[str]:
return super()._get_text_of_elements(self.__frequent_topic_all_cards)
def get_all_frequent_topics_cards(self) -> list[str]:
return self._get_text_of_elements(self.__frequent_topic_all_cards)

def _get_frequent_topics_subtitle_text(self) -> str:
return super()._get_text_of_element(self.__frequent_topics_section_subtitle)
def get_frequent_topics_subtitle_text(self) -> str:
return self._get_text_of_element(self.__frequent_topics_section_subtitle)

def _click_on_a_particular_frequent_topic_card(self, card_title: str):
super()._click(f"//h2[contains(text(),'Frequent Topics')]/../../../..//"
f"a[normalize-space(text())='{card_title}']")
def click_on_a_particular_frequent_topic_card(self, card_title: str):
self._click(f"//h2[contains(text(),'Frequent Topics')]/../../../..//a[normalize-space("
f"text())='{card_title}']")

def _get_featured_articles_header_text(self) -> str:
return super()._get_text_of_element(self.__featured_article_section_title)
def get_featured_articles_header_text(self) -> str:
return self._get_text_of_element(self.__featured_article_section_title)

def _is_featured_articles_section_displayed(self) -> bool:
return super()._is_element_visible(self.__featured_article_section_title)
def is_featured_articles_section_displayed(self) -> bool:
return self._is_element_visible(self.__featured_article_section_title)

def _get_list_of_featured_articles_headers(self) -> list[str]:
return super()._get_text_of_elements(self.__featured_articles_cards)
def get_list_of_featured_articles_headers(self) -> list[str]:
return self._get_text_of_elements(self.__featured_articles_cards)

def _get_feature_articles_count(self) -> int:
return len(super()._get_text_of_elements(self.__featured_articles_cards))
def get_feature_articles_count(self) -> int:
return len(self._get_text_of_elements(self.__featured_articles_cards))

def _click_on_a_particular_feature_article_card(self, card_title):
super()._click(f'//h2[contains(text(),"Featured Articles")]/..//a[text()="{card_title}"]')
def click_on_a_particular_feature_article_card(self, card_title):
self._click(f'//h2[contains(text(),"Featured Articles")]/..//a[normalize-space(text())'
f'="{card_title}"]')

def _get_still_need_help_widget_title(self) -> str:
return super()._get_text_of_element(self.__still_need_help_widget_title)
def is_still_need_help_widget_displayed(self) -> bool:
return self._is_element_visible(self.__still_need_help_widget)

def _get_still_need_help_widget_content(self) -> str:
return super()._get_text_of_element(self.__still_need_help_widget_details)
def get_still_need_help_widget_title(self) -> str:
return self._get_text_of_element(self.__still_need_help_widget_title)

def _get_still_need_help_widget_button_text(self) -> str:
return super()._get_text_of_element(self.__ask_the_community_still_need_help_widget)
def get_still_need_help_widget_content(self) -> str:
return self._get_text_of_element(self.__still_need_help_widget_details)

def _click_still_need_help_widget_button(self):
super()._click(self.__ask_the_community_still_need_help_widget)
def get_still_need_help_widget_button_text(self) -> str:
return self._get_text_of_element(self.__ask_the_community_still_need_help_widget)

def _get_join_our_community_header_text(self) -> str:
return super()._get_text_of_element(self.__join_our_community_section_header)
def click_still_need_help_widget_button(self):
self._click(self.__ask_the_community_still_need_help_widget)

def _get_join_our_community_content_text(self) -> str:
return super()._get_text_of_elements(
def get_join_our_community_header_text(self) -> str:
return self._get_text_of_element(self.__join_our_community_section_header)

def get_join_our_community_content_text(self) -> str:
return self._get_text_of_elements(
self.__join_our_community_section_paragraph_and_learn_more_option
)[0]

def _click_join_our_community_learn_more_link(self):
return (super()._click_on_an_element_by_index
def click_join_our_community_learn_more_link(self):
return (self._click_on_an_element_by_index
(self.__join_our_community_section_paragraph_and_learn_more_option, 1)
)
7 changes: 7 additions & 0 deletions playwright_tests/pages/top_navbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class TopNavbar(BasePage):
"normalize-space(text())='Media gallery']"
)

__guides_option = ("//ul[@class='mzp-c-menu-item-list sumo-nav--sublist']//a[normalize-space("
"text())='Guides']")

"""
Locators belonging to the username section of the top-navbar.
"""
Expand Down Expand Up @@ -219,6 +222,10 @@ def click_on_media_gallery_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__media_gallery_option)

def click_on_guides_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__guides_option)

"""
Actions against the sign-in/sign-up top-navbar section.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ def test_products_page_content(page: Page):
sumo_pages = SumoPages(page)
utilities = Utilities(page)
sumo_pages.top_navbar.click_on_explore_our_help_articles_view_all_option()
assert sumo_pages.products_page._get_page_header(
assert sumo_pages.products_page.get_page_header(
) == ProductsPageMessages.PRODUCTS_PAGE_HEADER

with allure.step("Clicking on the first 'Home' breadcrumb and verifying the redirect"):
sumo_pages.products_page._click_on_first_breadcrumb()
sumo_pages.products_page.click_on_first_breadcrumb()
expect(page).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL_EN_US)

with allure.step("Navigating back to the 'Products' page"):
utilities.navigate_back()

for card in sumo_pages.products_page._get_all_product_support_titles():
for card in sumo_pages.products_page.get_all_product_support_titles():
with check, allure.step(f"Verifying that the {card} card contains the correct "
f"subheading"):
if card in ProductsPageMessages.PRODUCT_CARDS_SUBHEADING:
assert sumo_pages.products_page._get_subheading_of_card(
assert sumo_pages.products_page.get_subheading_of_card(
card) == ProductsPageMessages.PRODUCT_CARDS_SUBHEADING[card]


Expand All @@ -45,11 +45,11 @@ def test_products_page_card_redirect(page: Page):
with allure.step("Navigating to products page via top-navbar"):
sumo_pages.top_navbar.click_on_explore_our_help_articles_view_all_option()

for card in sumo_pages.products_page._get_all_product_support_titles():
for card in sumo_pages.products_page.get_all_product_support_titles():
if card in utilities.general_test_data['product_support']:
with allure.step(f"Clicking on {card} card and verifying that we are redirected "
f"to the correct product url"):
sumo_pages.products_page._click_on_a_particular_product_support_card(card)
sumo_pages.products_page.click_on_a_particular_product_support_card(card)
expect(page).to_have_url(utilities.general_test_data['product_support'][card])

with allure.step("Navigating back to the products page"):
Expand Down
Loading

0 comments on commit 98e8391

Please sign in to comment.