Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright refactor EditProfileDataFlow, Top Navbar and user_pages classes #6232

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions playwright_tests/flows/user_profile_flows/edit_profile_data_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,79 @@
from playwright_tests.pages.user_pages.my_profile_user_navbar import UserNavbar


class EditProfileDataFlow(MyProfileEdit,
Utilities,
MyProfileEditContributionAreasPage,
TopNavbar,
UserNavbar,
MyProfileEditSettingsPage):
class EditProfileDataFlow:
def __init__(self, page: Page):
super().__init__(page)
self.utilities = Utilities(page)
self.edit_profile_page = MyProfileEdit(page)
self.top_navbar = TopNavbar(page)
self.edit_settings_page = MyProfileEditSettingsPage(page)
self.profile_navbar = UserNavbar(page)
self.profile_contribution_areas = MyProfileEditContributionAreasPage(page)

# Editing a profile with data flow.
def edit_profile_with_test_data(self):
edit_test_data = super().profile_edit_test_data
edit_test_data = self.utilities.profile_edit_test_data

self._clear_input_fields()
super()._send_text_to_username_field(edit_test_data["valid_user_edit"]["username"])
super()._send_text_to_display_name_field(edit_test_data["valid_user_edit"]["display_name"])
super()._send_text_to_biography_field(edit_test_data["valid_user_edit"]["biography"])
super()._send_text_to_website_field(edit_test_data["valid_user_edit"]["website"])
super()._send_text_to_twitter_username_field(
self.edit_profile_page.send_text_to_username_field(
edit_test_data["valid_user_edit"]["username"]
)
self.edit_profile_page.send_text_to_display_name_field(
edit_test_data["valid_user_edit"]["display_name"]
)
self.edit_profile_page.send_text_to_biography_field(
edit_test_data["valid_user_edit"]["biography"]
)
self.edit_profile_page.send_text_to_website_field(
edit_test_data["valid_user_edit"]["website"]
)
self.edit_profile_page.send_text_to_twitter_username_field(
edit_test_data["valid_user_edit"]["twitter_username"]
)
super()._send_text_to_community_portal_field(
self.edit_profile_page.send_text_to_community_portal_field(
edit_test_data["valid_user_edit"]["community_portal_username"]
)
super()._send_text_to_people_directory_username(
self.edit_profile_page.send_text_to_people_directory_username(
edit_test_data["valid_user_edit"]["people_directory_username"]
)
super()._send_text_to_matrix_nickname(
self.edit_profile_page.send_text_to_matrix_nickname(
edit_test_data["valid_user_edit"]["matrix_nickname"]
)
super()._select_country_dropdown_option_by_value(
self.edit_profile_page.select_country_dropdown_option_by_value(
edit_test_data["valid_user_edit"]["country_code"]
)
super()._sent_text_to_city_field(edit_test_data["valid_user_edit"]["city"])
super()._select_timezone_dropdown_option_by_value(
self.edit_profile_page.sent_text_to_city_field(edit_test_data["valid_user_edit"]["city"])
self.edit_profile_page.select_timezone_dropdown_option_by_value(
edit_test_data["valid_user_edit"]["timezone"]
)
super()._select_preferred_language_dropdown_option_by_value(
self.edit_profile_page.select_preferred_language_dropdown_option_by_value(
edit_test_data["valid_user_edit"]["preferred_language"]
)
super()._select_involved_from_month_option_by_value(
self.edit_profile_page.select_involved_from_month_option_by_value(
edit_test_data["valid_user_edit"]["involved_from_month_number"]
)
super()._select_involved_from_year_option_by_value(
self.edit_profile_page.select_involved_from_year_option_by_value(
edit_test_data["valid_user_edit"]["involved_from_year"]
)

# Clear all profile edit input fields flow.
def _clear_input_fields(self):
super()._clear_all_input_fields()
super()._clear_username_field()
super()._clear_biography_textarea_field()
self.edit_profile_page.clear_all_input_fields()
self.edit_profile_page.clear_username_field()
self.edit_profile_page.clear_biography_textarea_field()

def check_all_user_settings(self):
super()._click_on_settings_profile_option()
super()._click_on_all_settings_checkboxes()
super()._click_on_update_button()
self.top_navbar.click_on_settings_profile_option()
self.edit_settings_page.click_on_all_settings_checkboxes()
self.edit_settings_page.click_on_update_button()

def check_all_profile_contribution_areas(self, checked: bool):
super()._click_on_settings_profile_option()
super()._click_on_edit_contribution_areas_option()
self.top_navbar.click_on_settings_profile_option()
self.profile_navbar.click_on_edit_contribution_areas_option()

if not checked:
super()._click_on_unchecked_cont_areas_checkboxes()
self.profile_contribution_areas.click_on_unchecked_cont_areas_checkboxes()
else:
super()._click_on_all_checked_cont_areas_checkboxes()
self.profile_contribution_areas.click_on_all_checked_cont_areas_checkboxes()

super()._click_on_update_contribution_areas_button()
self.profile_contribution_areas.click_on_update_contribution_areas_button()
166 changes: 83 additions & 83 deletions playwright_tests/pages/top_navbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,146 +120,146 @@ def __init__(self, page: Page):
"""
Actions against the top-navbar logo.
"""
def _get_sumo_nav_logo(self) -> ElementHandle:
return super()._get_element_handle(self.__sumo_nav_logo)
def get_sumo_nav_logo(self) -> ElementHandle:
return self._get_element_handle(self.__sumo_nav_logo)

def _click_on_sumo_nav_logo(self):
super()._click(self.__sumo_nav_logo)
def click_on_sumo_nav_logo(self):
self._click(self.__sumo_nav_logo)

"""
Actions against the 'Explore Help Articles' top-navbar section.
"""
def _hover_over_explore_by_product_top_navbar_option(self):
super()._hover_over_element(self.__explore_help_articles_top_navbar_option)
def hover_over_explore_by_product_top_navbar_option(self):
self._hover_over_element(self.__explore_help_articles_top_navbar_option)

def _get_all_explore_by_product_options_locators(self) -> list[Locator]:
self._hover_over_explore_by_product_top_navbar_option()
def get_all_explore_by_product_options_locators(self) -> list[Locator]:
self.hover_over_explore_by_product_top_navbar_option()
self.page.wait_for_selector(self.__explore_by_product_top_navbar_header)
return super()._get_elements_locators(self.__explore_by_product_top_navbar_options)
return self._get_elements_locators(self.__explore_by_product_top_navbar_options)

def _get_all_explore_by_topic_locators(self) -> list[Locator]:
self._hover_over_explore_by_product_top_navbar_option()
def get_all_explore_by_topic_locators(self) -> list[Locator]:
self.hover_over_explore_by_product_top_navbar_option()
self.page.wait_for_selector(self.__explore_by_topic_top_navbar_header)
return super()._get_elements_locators(self.__explore_by_topic_top_navbar_options)
return self._get_elements_locators(self.__explore_by_topic_top_navbar_options)

def _click_on_explore_our_help_articles_view_all_option(self):
super()._hover_over_element(self.__explore_help_articles_top_navbar_option)
super()._click(self.__explore_our_help_articles_view_all_option)
def click_on_explore_our_help_articles_view_all_option(self):
self._hover_over_element(self.__explore_help_articles_top_navbar_option)
self._click(self.__explore_our_help_articles_view_all_option)
"""
Actions against the 'Community Forums' top-navbar section.
"""
def _hover_over_community_forums_top_navbar_option(self):
super()._hover_over_element(self.__community_forums_top_navbar_option)
def hover_over_community_forums_top_navbar_option(self):
self._hover_over_element(self.__community_forums_top_navbar_option)

def _get_all_browse_by_product_options_locators(self) -> list[Locator]:
self._hover_over_community_forums_top_navbar_option()
def get_all_browse_by_product_options_locators(self) -> list[Locator]:
self.hover_over_community_forums_top_navbar_option()
self.page.wait_for_selector(self.__browse_by_product_top_navbar_header)
return super()._get_elements_locators(self.__browse_by_product_top_navbar_options)
return self._get_elements_locators(self.__browse_by_product_top_navbar_options)

def _get_all_browse_all_forum_threads_by_topic_locators(self) -> list[Locator]:
self._hover_over_community_forums_top_navbar_option()
def get_all_browse_all_forum_threads_by_topic_locators(self) -> list[Locator]:
self.hover_over_community_forums_top_navbar_option()
self.page.wait_for_selector(self.__browse_all_forum_threads_by_topic_top_navbar_header)
return super()._get_elements_locators(
return self._get_elements_locators(
self.__browse_all_forum_threads_by_topics_top_navbar_options)

"""
Actions against the 'Ask a Question' top-navbar section.
"""
def _hover_over_ask_a_question_top_navbar(self):
super()._hover_over_element(self.__ask_a_question_top_navbar)
def hover_over_ask_a_question_top_navbar(self):
self._hover_over_element(self.__ask_a_question_top_navbar)

def _get_all_ask_a_question_locators(self) -> list[Locator]:
super()._hover_over_element(self.__ask_a_question_top_navbar)
def get_all_ask_a_question_locators(self) -> list[Locator]:
self._hover_over_element(self.__ask_a_question_top_navbar)
self.page.wait_for_selector(self.__get_help_with_heading)
return super()._get_elements_locators(self.__ask_a_question_top_navbar_options)
return self._get_elements_locators(self.__ask_a_question_top_navbar_options)

def _click_on_browse_all_products_option(self):
super()._hover_over_element(self.__ask_a_question_top_navbar)
super()._click(self.__browse_all_products_option)
def click_on_browse_all_products_option(self):
self._hover_over_element(self.__ask_a_question_top_navbar)
self._click(self.__browse_all_products_option)

"""
Actions against the 'Contribute' top-navbar section.
"""
def _hover_over_contribute_top_navbar(self):
super()._hover_over_element(self.__contribute_option)
def hover_over_contribute_top_navbar(self):
self._hover_over_element(self.__contribute_option)

def _get_all_contributor_discussions_locators(self) -> list[Locator]:
self._hover_over_contribute_top_navbar()
def get_all_contributor_discussions_locators(self) -> list[Locator]:
self.hover_over_contribute_top_navbar()
self.page.wait_for_selector(self.__contributor_discussions_top_navbar_header)
return super()._get_elements_locators(self.__contributor_discussions_options)
return self._get_elements_locators(self.__contributor_discussions_options)

def _click_on_contribute_top_navbar_option(self):
super()._click(self.__contribute_option)
def click_on_contribute_top_navbar_option(self):
self._click(self.__contribute_option)

def _click_on_community_discussions_top_navbar_option(self):
self._hover_over_contribute_top_navbar()
super()._click(self.__contributor_discussions_option)
def click_on_community_discussions_top_navbar_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__contributor_discussions_option)

def _click_on_article_discussions_option(self):
super()._hover_over_element(self.__contribute_option)
super()._click(self.__article_discussions_option)
def click_on_article_discussions_option(self):
self._hover_over_element(self.__contribute_option)
self._click(self.__article_discussions_option)

# Contributor tools
def _click_on_moderate_forum_content_option(self):
self._hover_over_contribute_top_navbar()
super()._click(self.__moderate_forum_content)
def click_on_moderate_forum_content_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__moderate_forum_content)

def _click_on_recent_revisions_option(self):
self._hover_over_contribute_top_navbar()
super()._click(self.__recent_revisions_option)
def click_on_recent_revisions_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__recent_revisions_option)

def _click_on_dashboards_option(self):
self._hover_over_contribute_top_navbar()
super()._click(self.__dashboards_option)
def click_on_dashboards_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__dashboards_option)

def _click_on_media_gallery_option(self):
self._hover_over_contribute_top_navbar()
super()._click(self.__media_gallery_option)
def click_on_media_gallery_option(self):
self.hover_over_contribute_top_navbar()
self._click(self.__media_gallery_option)

"""
Actions against the sign-in/sign-up top-navbar section.
"""
def _click_on_signin_signup_button(self):
super()._click(self.__signin_signup_button)
def click_on_signin_signup_button(self):
self._click(self.__signin_signup_button)

def _click_on_sign_out_button(self):
super()._hover_over_element(self.__signed_in_username)
super()._click(self.__sign_out_button)
def click_on_sign_out_button(self):
self._hover_over_element(self.__signed_in_username)
self._click(self.__sign_out_button)

def _sign_in_up_button_displayed_element(self) -> Locator:
return super()._get_element_locator(self.__signin_signup_button)
def sign_in_up_button_displayed_element(self) -> Locator:
return self._get_element_locator(self.__signin_signup_button)

def is_sign_in_up_button_displayed(self) -> bool:
return super()._is_element_visible(self.__signin_signup_button)
return self._is_element_visible(self.__signin_signup_button)

"""
Actions against the user profile top-navbar section.
"""
def _click_on_view_profile_option(self):
super()._hover_over_element(self.__signed_in_username)
super()._click(self.__signed_in_view_profile_option)
def click_on_view_profile_option(self):
self._hover_over_element(self.__signed_in_username)
self._click(self.__signed_in_view_profile_option)

def _click_on_edit_profile_option(self):
super()._hover_over_element(self.__signed_in_username)
super()._click(self.__signed_in_edit_profile_option)
def click_on_edit_profile_option(self):
self._hover_over_element(self.__signed_in_username)
self._click(self.__signed_in_edit_profile_option)

def _click_on_settings_profile_option(self):
super()._hover_over_element(self.__signed_in_username)
super()._click(self.__signed_in_settings_option)
def click_on_settings_profile_option(self):
self._hover_over_element(self.__signed_in_username)
self._click(self.__signed_in_settings_option)

def _click_on_inbox_option(self):
super()._hover_over_element(self.__signed_in_username)
super()._click(self.__signed_in_inbox_option)
def click_on_inbox_option(self):
self._hover_over_element(self.__signed_in_username)
self._click(self.__signed_in_inbox_option)

def _click_on_my_questions_profile_option(self):
super()._hover_over_element(self.__signed_in_username)
super()._click(self.__signed_in_my_questions_option)
def click_on_my_questions_profile_option(self):
self._hover_over_element(self.__signed_in_username)
self._click(self.__signed_in_my_questions_option)

def _get_text_of_logged_in_username(self) -> str:
return super()._get_text_of_element(self.__signed_in_username)
def get_text_of_logged_in_username(self) -> str:
return self._get_text_of_element(self.__signed_in_username)

"""
General actions against the top-navbar section.
"""
def _get_available_menu_titles(self) -> list[str]:
return super()._get_text_of_elements(self.__menu_titles)
def get_available_menu_titles(self) -> list[str]:
return self._get_text_of_elements(self.__menu_titles)
Loading