Skip to content

Commit

Permalink
Merge pull request #6133 from emilghittasv/expand-playwright-top-navb…
Browse files Browse the repository at this point in the history
…ar-coverage

Expand playwright coverage over the new top-navbar options
  • Loading branch information
emilghittasv authored Jul 22, 2024
2 parents 4ea3bae + c25974e commit 99d6154
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 49 deletions.
14 changes: 13 additions & 1 deletion playwright_tests/core/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def _get_text_of_element(self, xpath: str) -> str:
"""
return self._get_element_locator(xpath).inner_text()

def _get_text_of_locator(self, locator: Locator) -> str:
"""
This helper function returns the inner text of a given locator.
"""
return locator.inner_text()

def _is_element_empty(self, xpath: str) -> bool:
"""
This helper function returns checks if the given xpath has an inner text.
Expand Down Expand Up @@ -192,10 +198,16 @@ def _hover_over_element(self, xpath: str):

def _is_element_visible(self, xpath: str) -> bool:
"""
This helper function checks if a given element locator is visible.
This helper function finds the locator of the given xpath and checks if it is visible.
"""
return self._get_element_locator(xpath).is_visible()

def _is_locator_visible(self, locator: Locator) -> bool:
"""
This helper function checks if the given locator is visible.
"""
return locator.is_visible()

def _is_checkbox_checked(self, xpath: str) -> bool:
"""
This helper function checks if a given element locator is checked.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from playwright.sync_api import Page
from playwright_tests.core.basepage import BasePage

Expand All @@ -15,6 +17,7 @@ class ProductSupportForum(BasePage):

# Side navbar filter options
__side_navbar_filter_options = "//ul[@class='sidebar-nav--list']//a"
__topic_dropdown_selected_option = "//select[@id='products-topics-dropdown']/option[@selected]"

# Question list
__all_question_list_tags = "//li[@class='tag']"
Expand All @@ -27,6 +30,10 @@ def __init__(self, page: Page):
def _click_on_the_ask_the_community_button(self):
super()._click(self.__ask_the_community_button)

def _get_selected_topic_option(self) -> str:
option = super()._get_text_of_element(self.__topic_dropdown_selected_option)
return re.sub(r'\s+', ' ', option).strip()

# Showing Questions Tagged section actions
def _get_text_of_selected_tag_filter_option(self) -> str:
return super()._get_text_of_element(self.__showing_questions_tagged_tag)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from playwright.sync_api import Page
from playwright_tests.core.basepage import BasePage

"""
This class contains the locators and actions for the general "Contributor Discussions" page.
"""


class ContributorDiscussionPage(BasePage):
__contributor_discussions_page_title = "//div[@id='forums']/h1"

def __init__(self, page: Page):
super().__init__(page)

def _get_contributor_discussions_page_title(self) -> str:
return super()._get_text_of_element(self.__contributor_discussions_page_title)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import re
from playwright.sync_api import Page
from playwright_tests.core.basepage import BasePage

"""
This class contains the locators and actions for the {x} discussions page.
"""


class DiscussionsPage(BasePage):
__discussions_page_title = "//article[@id='threads']/h1"
__contributor_discussions_side_nav_selected_option = ("//nav[@id='for-contributors-sidebar']//"
"a[@class='selected']")

def __init__(self, page: Page):
super().__init__(page)

def _get_contributor_discussions_page_title(self) -> str:
return super()._get_text_of_element(self.__discussions_page_title)

def _get_contributor_discussions_side_nav_selected_option(self) -> str:
option = super()._get_text_of_element(
self.__contributor_discussions_side_nav_selected_option)
return re.sub(r'\s+', ' ', option).strip()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import re

from playwright.sync_api import Page

from playwright_tests.core.basepage import BasePage


class ExploreByTopicPage(BasePage):
__explore_by_topic_page_header = "//div[@class='documents-product-title']/h1"
__filter_by_product_dropdown_selected_option = ("//select[@id='products-topics-dropdown"
"']/option[@selected]")
__all_topics_side_navbar_options = "//ul[@class='sidebar-nav--list']/li/a"
__all_topics_selected_option = ("//ul[@class='sidebar-nav--list']/li/a[contains(@class, "
"'selected')]")
__AAQ_widget_continue_button = ("//div[@class='aaq-widget card is-inverse elevation-01 "
"text-center radius-md']/a")
__AAQ_widget_text = ("//div[@class='aaq-widget card is-inverse elevation-01 text-center "
"radius-md']/p")
__volunteer_learn_more_option = "//section[@id='get-involved-button']//a"

def __init__(self, page: Page):
super().__init__(page)

def _get_explore_by_topic_page_header(self) -> str:
return super()._get_text_of_element(self.__explore_by_topic_page_header)

def _get_selected_topic_side_navbar_option(self) -> str:
return super()._get_text_of_element(self.__all_topics_selected_option)

def _get_current_topic_filter_dropdown_option(self) -> str:
option = super()._get_text_of_element(self.__filter_by_product_dropdown_selected_option)
return re.sub(r'\s+', ' ', option).strip()
10 changes: 10 additions & 0 deletions playwright_tests/pages/sumo_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
from playwright_tests.flows.user_groups_flows.user_group_flow import UserGroupFlow
from playwright_tests.flows.user_profile_flows.edit_profile_data_flow import EditProfileDataFlow
from playwright_tests.pages.ask_a_question.aaq_pages.aaq_form_page import AAQFormPage
from playwright_tests.pages.contribute.contribute_pages.contributor_discussions_pages.\
contributor_discussions_page import ContributorDiscussionPage
from playwright_tests.pages.contribute.contribute_pages.contributor_discussions_pages.\
discussions_page import DiscussionsPage
from playwright_tests.pages.contribute.contributor_tools_pages.article_discussions_page import \
ArticleDiscussionsPage
from playwright_tests.pages.contribute.contributor_tools_pages.kb_dashboard_page import KBDashboard
Expand Down Expand Up @@ -59,6 +63,7 @@
from playwright_tests.pages.contribute.contribute_pages.contribute_page import ContributePage
from playwright_tests.pages.contribute.contribute_pages.ways_to_contribute_pages import (
WaysToContributePages)
from playwright_tests.pages.explore_help_articles.explore_by_topic_page import ExploreByTopicPage
from playwright_tests.pages.footer import FooterSection
from playwright_tests.pages.community_forums.forums_pages.product_support_forum import (
ProductSupportForum)
Expand Down Expand Up @@ -135,6 +140,7 @@ def __init__(self, page: Page):

# Explore our help articles products page.
self.products_page = ProductsPage(page)
self.explore_by_product_page = ExploreByTopicPage(page)

# KB Articles.
self.kb_submit_kb_article_form_page = SubmitKBArticlePage(page)
Expand Down Expand Up @@ -183,6 +189,10 @@ def __init__(self, page: Page):
# Moderate Forum Page
self.moderate_forum_content_page = ModerateForumContent(page)

# Discussions pages
self.contributor_discussions_page = ContributorDiscussionPage(page)
self.discussions_page = DiscussionsPage(page)

# Auth flow Page.
self.auth_flow_page = AuthFlowPage(page)

Expand Down
Loading

0 comments on commit 99d6154

Please sign in to comment.